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