pidwait: Rename from pwait

pwait is already in at least Debian in a different package

References:
 https://bugs.debian.org/982391
This commit is contained in:
Craig Small 2021-02-15 21:10:06 +11:00
parent 19a508ea12
commit 52afb3a8d3
7 changed files with 41 additions and 37 deletions

2
.gitignore vendored
View File

@ -42,7 +42,7 @@ pgrep
pidof pidof
pkill pkill
pmap pmap
pwait pidwait
procps-ng-*.tar.xz procps-ng-*.tar.xz
proc/.depend proc/.depend
proc/libprocps.la proc/libprocps.la

View File

@ -49,8 +49,8 @@ bin_PROGRAMS = \
uptime \ uptime \
vmstat \ vmstat \
w w
if BUILD_PWAIT if BUILD_PIDWAIT
bin_PROGRAMS += pwait bin_PROGRAMS += pidwait
endif endif
else else
usrbin_exec_PROGRAMS += \ usrbin_exec_PROGRAMS += \
@ -85,8 +85,8 @@ dist_man_MANS += \
sysctl.conf.5 \ sysctl.conf.5 \
ps/ps.1 ps/ps.1
if BUILD_PWAIT if BUILD_PIDWAIT
dist_man_MANS += pwait.1 dist_man_MANS += pidwait.1
endif endif
endif endif
@ -199,8 +199,8 @@ free_SOURCES = free.c lib/strutils.c lib/fileutils.c
pgrep_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c pgrep_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
pkill_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c pkill_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
pmap_SOURCES = pmap.c lib/fileutils.c pmap_SOURCES = pmap.c lib/fileutils.c
if BUILD_PWAIT if BUILD_PIDWAIT
pwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c pidwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
endif endif
if !CYGWIN if !CYGWIN
pwdx_SOURCES = pwdx.c lib/fileutils.c pwdx_SOURCES = pwdx.c lib/fileutils.c

4
NEWS
View File

@ -1,3 +1,7 @@
procps-ng-NEXT
---------------
* Rename pwait to pidwait
procps-ng-3.3.17 procps-ng-3.3.17
--------------- ---------------
* library: Incremented to 8:3:0 * library: Incremented to 8:3:0

View File

@ -132,20 +132,20 @@ AC_TRY_COMPILE([#include <errno.h>],
AC_MSG_RESULT(yes), AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)) AC_MSG_RESULT(no))
AC_CHECK_FUNC([pidfd_open], [enable_pwait=yes], [ AC_CHECK_FUNC([pidfd_open], [enable_pidwait=yes], [
AC_MSG_CHECKING([for __NR_pidfd_open]) AC_MSG_CHECKING([for __NR_pidfd_open])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/syscall.h> #include <sys/syscall.h>
#ifndef __NR_pidfd_open #ifndef __NR_pidfd_open
#error __NR_pidfd_open not defined #error __NR_pidfd_open not defined
#endif #endif
])], [enable_pwait=yes], [enable_pwait=no]) ])], [enable_pidwait=yes], [enable_pidwait=no])
AC_MSG_RESULT([$enable_pwait]) AC_MSG_RESULT([$enable_pidwait])
]) ])
if test "$enable_pwait" = yes; then if test "$enable_pidwait" = yes; then
AC_DEFINE([ENABLE_PWAIT], [1], [Enable pwait]) AC_DEFINE([ENABLE_PIDWAIT], [1], [Enable pidwait])
fi fi
AM_CONDITIONAL([BUILD_PWAIT], [test x$enable_pwait = xyes]) AM_CONDITIONAL([BUILD_PIDWAIT], [test x$enable_pidwait = xyes])
dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses
AC_SUBST([WITH_WATCH8BIT]) AC_SUBST([WITH_WATCH8BIT])

22
pgrep.1
View File

@ -9,7 +9,7 @@
.\" .\"
.TH PGREP "1" "2020-06-04" "procps-ng" "User Commands" .TH PGREP "1" "2020-06-04" "procps-ng" "User Commands"
.SH NAME .SH NAME
pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and other attributes pgrep, pkill, pidwait \- look up, signal, or wait for processes based on name and other attributes
.SH SYNOPSIS .SH SYNOPSIS
.B pgrep .B pgrep
[options] pattern [options] pattern
@ -17,7 +17,7 @@ pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and
.B pkill .B pkill
[options] pattern [options] pattern
.br .br
.B pwait .B pidwait
[options] pattern [options] pattern
.SH DESCRIPTION .SH DESCRIPTION
.B pgrep .B pgrep
@ -45,7 +45,7 @@ will send the specified signal (by default
.BR SIGTERM ) .BR SIGTERM )
to each process instead of listing them on stdout. to each process instead of listing them on stdout.
.PP .PP
.B pwait .B pidwait
will wait for each process instead of listing them on stdout. will wait for each process instead of listing them on stdout.
.SH OPTIONS .SH OPTIONS
.TP .TP
@ -60,7 +60,7 @@ only.)
\fB\-c\fR, \fB\-\-count\fR \fB\-c\fR, \fB\-\-count\fR
Suppress normal output; instead print a count of matching processes. When Suppress normal output; instead print a count of matching processes. When
count does not match anything, e.g. returns zero, the command will return count does not match anything, e.g. returns zero, the command will return
non-zero value. Note that for pkill and pwait, the count is the number of non-zero value. Note that for pkill and pidwait, the count is the number of
matching processes, not the processes that were successfully signaled or waited matching processes, not the processes that were successfully signaled or waited
for. for.
.TP .TP
@ -88,7 +88,7 @@ translated into
.BR pgrep 's, .BR pgrep 's,
.BR pkill 's, .BR pkill 's,
or or
.BR pwait 's .BR pidwait 's
own process group. own process group.
.TP .TP
\fB\-G\fR, \fB\-\-group\fR \fIgid\fP,... \fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
@ -126,7 +126,7 @@ is translated into
.BR pgrep 's, .BR pgrep 's,
.BR pkill 's, .BR pkill 's,
or or
.BR pwait 's .BR pidwait 's
own session ID. own session ID.
.TP .TP
\fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,... \fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,...
@ -145,7 +145,7 @@ symbolical value may be used.
Negates the matching. This option is usually used in Negates the matching. This option is usually used in
.BR pgrep 's .BR pgrep 's
or or
.BR pwait 's .BR pidwait 's
context. In context. In
.BR pkill 's .BR pkill 's
context the short option is disabled to avoid accidental usage of the option. context the short option is disabled to avoid accidental usage of the option.
@ -154,7 +154,7 @@ context the short option is disabled to avoid accidental usage of the option.
Shows all thread ids instead of pids in Shows all thread ids instead of pids in
.BR pgrep 's .BR pgrep 's
or or
.BR pwait 's .BR pidwait 's
context. In context. In
.BR pkill 's .BR pkill 's
context this option is disabled. context this option is disabled.
@ -167,7 +167,7 @@ match the
.TP .TP
\fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR \fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
Read \fIPID\fRs from \fIfile\fR. This option is more useful for Read \fIPID\fRs from \fIfile\fR. This option is more useful for
.BR pkill or pwait .BR pkill or pidwait
than than
.BR pgrep . .BR pgrep .
.TP .TP
@ -237,7 +237,7 @@ $ renice +4 $(pgrep chrome)
.PD 0 .PD 0
.TP .TP
0 0
One or more processes matched the criteria. For pkill and pwait, one or more One or more processes matched the criteria. For pkill and pidwait, one or more
processes must also have been successfully signalled or waited for. processes must also have been successfully signalled or waited for.
.TP .TP
1 1
@ -258,7 +258,7 @@ The running
.BR pgrep , .BR pgrep ,
.BR pkill , .BR pkill ,
or or
.B pwait .B pidwait
process will never report itself as a process will never report itself as a
match. match.
.SH BUGS .SH BUGS

26
pgrep.c
View File

@ -38,7 +38,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN) #if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
#include <sys/epoll.h> #include <sys/epoll.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#endif #endif
@ -68,8 +68,8 @@
static enum { static enum {
PGREP = 0, PGREP = 0,
PKILL, PKILL,
#ifdef ENABLE_PWAIT #ifdef ENABLE_PIDWAIT
PWAIT, PIDWAIT,
#endif #endif
} prog_mode; } prog_mode;
@ -136,8 +136,8 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
fputs(_(" -q, --queue <value> integer value to be sent with the signal\n"), fp); fputs(_(" -q, --queue <value> integer value to be sent with the signal\n"), fp);
fputs(_(" -e, --echo display what is killed\n"), fp); fputs(_(" -e, --echo display what is killed\n"), fp);
break; break;
#ifdef ENABLE_PWAIT #ifdef ENABLE_PIDWAIT
case PWAIT: case PIDWAIT:
fputs(_(" -e, --echo display PIDs before waiting\n"), fp); fputs(_(" -e, --echo display PIDs before waiting\n"), fp);
break; break;
#endif #endif
@ -687,7 +687,7 @@ static struct el * select_procs (int *num)
xerrx(EXIT_FAILURE, _("internal error")); xerrx(EXIT_FAILURE, _("internal error"));
} }
// pkill and pwait don't support -w, but this is checked in getopt // pkill and pidwait don't support -w, but this is checked in getopt
if (opt_threads) { if (opt_threads) {
while (readtask(ptp, &task, &subtask)){ while (readtask(ptp, &task, &subtask)){
// don't add redundant tasks // don't add redundant tasks
@ -742,7 +742,7 @@ static int signal_option(int *argc, char **argv)
return -1; return -1;
} }
#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN) #if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
static int pidfd_open (pid_t pid, unsigned int flags) static int pidfd_open (pid_t pid, unsigned int flags)
{ {
return syscall(__NR_pidfd_open, pid, flags); return syscall(__NR_pidfd_open, pid, flags);
@ -793,9 +793,9 @@ static void parse_opts (int argc, char **argv)
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
#ifdef ENABLE_PWAIT #ifdef ENABLE_PIDWAIT
if (strcmp (program_invocation_short_name, "pwait") == 0) { if (strcmp (program_invocation_short_name, "pidwait") == 0) {
prog_mode = PWAIT; prog_mode = PIDWAIT;
strcat (opts, "e"); strcat (opts, "e");
} else } else
#endif #endif
@ -1008,7 +1008,7 @@ int main (int argc, char **argv)
int num; int num;
int i; int i;
int kill_count = 0; int kill_count = 0;
#ifdef ENABLE_PWAIT #ifdef ENABLE_PIDWAIT
int poll_count = 0; int poll_count = 0;
int wait_count = 0; int wait_count = 0;
int epollfd = epoll_create(1); int epollfd = epoll_create(1);
@ -1055,8 +1055,8 @@ int main (int argc, char **argv)
fprintf(stdout, "%d\n", num); fprintf(stdout, "%d\n", num);
return !kill_count; return !kill_count;
#ifdef ENABLE_PWAIT #ifdef ENABLE_PIDWAIT
case PWAIT: case PIDWAIT:
if (opt_count) if (opt_count)
fprintf(stdout, "%d\n", num); fprintf(stdout, "%d\n", num);

View File