604d21
From 52afb3a8d31871d28b1c39573a7ed5196c2d5023 Mon Sep 17 00:00:00 2001
604d21
From: Craig Small <csmall@dropbear.xyz>
604d21
Date: Mon, 15 Feb 2021 21:10:06 +1100
604d21
Subject: [PATCH] pidwait: Rename from pwait
604d21
604d21
pwait is already in at least Debian in a different package
604d21
604d21
References:
604d21
 https://bugs.debian.org/982391
604d21
---
604d21
diff --git a/Makefile.am b/Makefile.am
604d21
index e037e4c..de15e13 100644
604d21
--- a/Makefile.am
604d21
+++ b/Makefile.am
604d21
@@ -49,8 +49,8 @@ bin_PROGRAMS = \
604d21
 	uptime \
604d21
 	vmstat \
604d21
 	w
604d21
-if BUILD_PWAIT
604d21
-bin_PROGRAMS += pwait
604d21
+if BUILD_PIDWAIT
604d21
+bin_PROGRAMS += pidwait
604d21
 endif
604d21
 else
604d21
 usrbin_exec_PROGRAMS += \
604d21
@@ -85,8 +85,8 @@ dist_man_MANS += \
604d21
 	sysctl.conf.5 \
604d21
 	ps/ps.1
604d21
 
604d21
-if BUILD_PWAIT
604d21
-dist_man_MANS += pwait.1
604d21
+if BUILD_PIDWAIT
604d21
+dist_man_MANS += pidwait.1
604d21
 endif
604d21
 endif
604d21
 
604d21
@@ -199,8 +199,8 @@ free_SOURCES = free.c lib/strutils.c lib/fileutils.c
604d21
 pgrep_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
604d21
 pkill_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
604d21
 pmap_SOURCES = pmap.c lib/fileutils.c
604d21
-if BUILD_PWAIT
604d21
-pwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
604d21
+if BUILD_PIDWAIT
604d21
+pidwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
604d21
 endif
604d21
 if !CYGWIN
604d21
 pwdx_SOURCES = pwdx.c lib/fileutils.c
604d21
diff --git a/NEWS b/NEWS
604d21
index da63c9c..5fe6761 100644
604d21
--- a/NEWS
604d21
+++ b/NEWS
604d21
@@ -1,3 +1,7 @@
604d21
+procps-ng-NEXT
604d21
+---------------
604d21
+  * Rename pwait to pidwait
604d21
+
604d21
 procps-ng-3.3.17
604d21
 ---------------
604d21
   * library: Incremented to 8:3:0
604d21
diff --git a/configure.ac b/configure.ac
604d21
index 56a8669..750c0fb 100644
604d21
--- a/configure.ac
604d21
+++ b/configure.ac
604d21
@@ -132,20 +132,20 @@ AC_TRY_COMPILE([#include <errno.h>],
604d21
 		AC_MSG_RESULT(yes),
604d21
 		AC_MSG_RESULT(no))
604d21
 
604d21
-AC_CHECK_FUNC([pidfd_open], [enable_pwait=yes], [
604d21
+AC_CHECK_FUNC([pidfd_open], [enable_pidwait=yes], [
604d21
   AC_MSG_CHECKING([for __NR_pidfd_open])
604d21
   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
604d21
 #include <sys/syscall.h>
604d21
 #ifndef __NR_pidfd_open
604d21
 #error __NR_pidfd_open not defined
604d21
 #endif
604d21
-    ])], [enable_pwait=yes], [enable_pwait=no])
604d21
-  AC_MSG_RESULT([$enable_pwait])
604d21
+    ])], [enable_pidwait=yes], [enable_pidwait=no])
604d21
+  AC_MSG_RESULT([$enable_pidwait])
604d21
 ])
604d21
-if test "$enable_pwait" = yes; then
604d21
-  AC_DEFINE([ENABLE_PWAIT], [1], [Enable pwait])
604d21
+if test "$enable_pidwait" = yes; then
604d21
+  AC_DEFINE([ENABLE_PIDWAIT], [1], [Enable pidwait])
604d21
 fi
604d21
-AM_CONDITIONAL([BUILD_PWAIT], [test x$enable_pwait = xyes])
604d21
+AM_CONDITIONAL([BUILD_PIDWAIT], [test x$enable_pidwait = xyes])
604d21
 
604d21
 dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses
604d21
 AC_SUBST([WITH_WATCH8BIT])
604d21
diff --git a/pgrep.1 b/pgrep.1
604d21
index 4f8907b..af6dcd5 100644
604d21
--- a/pgrep.1
604d21
+++ b/pgrep.1
604d21
@@ -9,7 +9,7 @@
604d21
 .\"
604d21
 .TH PGREP "1" "2020-06-04" "procps-ng" "User Commands"
604d21
 .SH NAME
604d21
-pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and other attributes
604d21
+pgrep, pkill, pidwait \- look up, signal, or wait for processes based on name and other attributes
604d21
 .SH SYNOPSIS
604d21
 .B pgrep
604d21
 [options] pattern
604d21
@@ -17,7 +17,7 @@ pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and
604d21
 .B pkill
604d21
 [options] pattern
604d21
 .br
604d21
-.B pwait
604d21
+.B pidwait
604d21
 [options] pattern
604d21
 .SH DESCRIPTION
604d21
 .B pgrep
604d21
@@ -45,7 +45,7 @@ will send the specified signal (by default
604d21
 .BR SIGTERM )
604d21
 to each process instead of listing them on stdout.
604d21
 .PP
604d21
-.B pwait
604d21
+.B pidwait
604d21
 will wait for each process instead of listing them on stdout.
604d21
 .SH OPTIONS
604d21
 .TP
604d21
@@ -60,7 +60,7 @@ only.)
604d21
 \fB\-c\fR, \fB\-\-count\fR
604d21
 Suppress normal output; instead print a count of matching processes.  When
604d21
 count does not match anything, e.g. returns zero, the command will return
604d21
-non-zero value. Note that for pkill and pwait, the count is the number of
604d21
+non-zero value. Note that for pkill and pidwait, the count is the number of
604d21
 matching processes, not the processes that were successfully signaled or waited
604d21
 for.
604d21
 .TP
604d21
@@ -88,7 +88,7 @@ translated into
604d21
 .BR pgrep 's,
604d21
 .BR pkill 's,
604d21
 or
604d21
-.BR pwait 's
604d21
+.BR pidwait 's
604d21
 own process group.
604d21
 .TP
604d21
 \fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
604d21
@@ -126,7 +126,7 @@ is translated into
604d21
 .BR pgrep 's,
604d21
 .BR pkill 's,
604d21
 or
604d21
-.BR pwait 's
604d21
+.BR pidwait 's
604d21
 own session ID.
604d21
 .TP
604d21
 \fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,...
604d21
@@ -145,7 +145,7 @@ symbolical value may be used.
604d21
 Negates the matching.  This option is usually used in
604d21
 .BR pgrep 's
604d21
 or
604d21
-.BR pwait 's
604d21
+.BR pidwait 's
604d21
 context.  In
604d21
 .BR pkill 's
604d21
 context the short option is disabled to avoid accidental usage of the option.
604d21
@@ -154,7 +154,7 @@ context the short option is disabled to avoid accidental usage of the option.
604d21
 Shows all thread ids instead of pids in
604d21
 .BR pgrep 's
604d21
 or
604d21
-.BR pwait 's
604d21
+.BR pidwait 's
604d21
 context.  In
604d21
 .BR pkill 's
604d21
 context this option is disabled.
604d21
@@ -167,7 +167,7 @@ match the
604d21
 .TP
604d21
 \fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
604d21
 Read \fIPID\fRs from \fIfile\fR.  This option is more useful for
604d21
-.BR pkill or pwait
604d21
+.BR pkill or pidwait
604d21
 than
604d21
 .BR pgrep .
604d21
 .TP
604d21
@@ -237,7 +237,7 @@ $ renice +4 $(pgrep chrome)
604d21
 .PD 0
604d21
 .TP
604d21
 0
604d21
-One or more processes matched the criteria. For pkill and pwait, one or more
604d21
+One or more processes matched the criteria. For pkill and pidwait, one or more
604d21
 processes must also have been successfully signalled or waited for.
604d21
 .TP
604d21
 1
604d21
@@ -258,7 +258,7 @@ The running
604d21
 .BR pgrep ,
604d21
 .BR pkill ,
604d21
 or
604d21
-.B pwait
604d21
+.B pidwait
604d21
 process will never report itself as a
604d21
 match.
604d21
 .SH BUGS
604d21
diff --git a/pgrep.c b/pgrep.c
604d21
index 4fe5e8a..1905cd1 100644
604d21
--- a/pgrep.c
604d21
+++ b/pgrep.c
604d21
@@ -38,7 +38,7 @@
604d21
 #include <stdbool.h>
604d21
 #include <time.h>
604d21
 
604d21
-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
604d21
+#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
604d21
 #include <sys/epoll.h>
604d21
 #include <sys/syscall.h>
604d21
 #endif
604d21
@@ -68,8 +68,8 @@
604d21
 static enum {
604d21
     PGREP = 0,
604d21
     PKILL,
604d21
-#ifdef ENABLE_PWAIT
604d21
-    PWAIT,
604d21
+#ifdef ENABLE_PIDWAIT
604d21
+    PIDWAIT,
604d21
 #endif
604d21
 } prog_mode;
604d21
 
604d21
@@ -136,8 +136,8 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
604d21
 		fputs(_(" -q, --queue <value>       integer value to be sent with the signal\n"), fp);
604d21
 		fputs(_(" -e, --echo                display what is killed\n"), fp);
604d21
 		break;
604d21
-#ifdef ENABLE_PWAIT
604d21
-	case PWAIT:
604d21
+#ifdef ENABLE_PIDWAIT
604d21
+	case PIDWAIT:
604d21
 		fputs(_(" -e, --echo                display PIDs before waiting\n"), fp);
604d21
 		break;
604d21
 #endif
604d21
@@ -687,7 +687,7 @@ static struct el * select_procs (int *num)
604d21
 				xerrx(EXIT_FAILURE, _("internal error"));
604d21
 			}
604d21
 
604d21
-			// pkill and pwait don't support -w, but this is checked in getopt
604d21
+			// pkill and pidwait don't support -w, but this is checked in getopt
604d21
 			if (opt_threads) {
604d21
 				while (readtask(ptp, &task, &subtask)){
604d21
 					// don't add redundant tasks
604d21
@@ -742,7 +742,7 @@ static int signal_option(int *argc, char **argv)
604d21
 	return -1;
604d21
 }
604d21
 
604d21
-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
604d21
+#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
604d21
 static int pidfd_open (pid_t pid, unsigned int flags)
604d21
 {
604d21
 	return syscall(__NR_pidfd_open, pid, flags);
604d21
@@ -793,9 +793,9 @@ static void parse_opts (int argc, char **argv)
604d21
 		{NULL, 0, NULL, 0}
604d21
 	};
604d21
 
604d21
-#ifdef ENABLE_PWAIT
604d21
-	if (strcmp (program_invocation_short_name, "pwait") == 0) {
604d21
-		prog_mode = PWAIT;
604d21
+#ifdef ENABLE_PIDWAIT
604d21
+	if (strcmp (program_invocation_short_name, "pidwait") == 0) {
604d21
+		prog_mode = PIDWAIT;
604d21
 		strcat (opts, "e");
604d21
 	} else
604d21
 #endif
604d21
@@ -1008,7 +1008,7 @@ int main (int argc, char **argv)
604d21
 	int num;
604d21
 	int i;
604d21
 	int kill_count = 0;
604d21
-#ifdef ENABLE_PWAIT
604d21
+#ifdef ENABLE_PIDWAIT
604d21
 	int poll_count = 0;
604d21
 	int wait_count = 0;
604d21
 	int epollfd = epoll_create(1);
604d21
@@ -1055,8 +1055,8 @@ int main (int argc, char **argv)
604d21
 			fprintf(stdout, "%d\n", num);
604d21
 		return !kill_count;
604d21
 
604d21
-#ifdef ENABLE_PWAIT
604d21
-	case PWAIT:
604d21
+#ifdef ENABLE_PIDWAIT
604d21
+	case PIDWAIT:
604d21
 		if (opt_count)
604d21
 			fprintf(stdout, "%d\n", num);
604d21
 
604d21
diff --git a/pwait.1 b/pidwait.1
604d21
similarity index 100%
604d21
rename from pwait.1
604d21
rename to pidwait.1
604d21
-- 
604d21
GitLab
604d21