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 779ca44b2d
commit 9c1a62b637
7 changed files with 43 additions and 37 deletions

2
.gitignore vendored
View File

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

View File

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

10
NEWS
View File

@ -1,5 +1,11 @@
procps-ng NEXT
--------------
procps-ng-NEXT
---------------
* Rename pwait to pidwait
procps-ng-3.3.17
---------------
* library: Incremented to 8:3:0
(no removals or additions, internal changes only)
* all: properly handle utf8 cmdline translations issue #176
* kill: Pass int to signalled process merge #32
* pgrep: Pass int to signalled process merge #32

View File

@ -133,20 +133,20 @@ AC_TRY_COMPILE([#include <errno.h>],
AC_MSG_RESULT(yes),
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_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/syscall.h>
#ifndef __NR_pidfd_open
#error __NR_pidfd_open not defined
#endif
])], [enable_pwait=yes], [enable_pwait=no])
AC_MSG_RESULT([$enable_pwait])
])], [enable_pidwait=yes], [enable_pidwait=no])
AC_MSG_RESULT([$enable_pidwait])
])
if test "$enable_pwait" = yes; then
AC_DEFINE([ENABLE_PWAIT], [1], [Enable pwait])
if test "$enable_pidwait" = yes; then
AC_DEFINE([ENABLE_PIDWAIT], [1], [Enable pidwait])
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
AC_SUBST([WITH_WATCH8BIT])

22
pgrep.1
View File

@ -9,7 +9,7 @@
.\"
.TH PGREP "1" "2020-06-04" "procps-ng" "User Commands"
.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
.B pgrep
[options] pattern
@ -17,7 +17,7 @@ pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and
.B pkill
[options] pattern
.br
.B pwait
.B pidwait
[options] pattern
.SH DESCRIPTION
.B pgrep
@ -45,7 +45,7 @@ will send the specified signal (by default
.BR SIGTERM )
to each process instead of listing them on stdout.
.PP
.B pwait
.B pidwait
will wait for each process instead of listing them on stdout.
.SH OPTIONS
.TP
@ -60,7 +60,7 @@ only.)
\fB\-c\fR, \fB\-\-count\fR
Suppress normal output; instead print a count of matching processes. When
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
for.
.TP
@ -88,7 +88,7 @@ translated into
.BR pgrep 's,
.BR pkill 's,
or
.BR pwait 's
.BR pidwait 's
own process group.
.TP
\fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
@ -126,7 +126,7 @@ is translated into
.BR pgrep 's,
.BR pkill 's,
or
.BR pwait 's
.BR pidwait 's
own session ID.
.TP
\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
.BR pgrep 's
or
.BR pwait 's
.BR pidwait 's
context. In
.BR pkill 's
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
.BR pgrep 's
or
.BR pwait 's
.BR pidwait 's
context. In
.BR pkill 's
context this option is disabled.
@ -167,7 +167,7 @@ match the
.TP
\fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
Read \fIPID\fRs from \fIfile\fR. This option is more useful for
.BR pkill or pwait
.BR pkill or pidwait
than
.BR pgrep .
.TP
@ -237,7 +237,7 @@ $ renice +4 $(pgrep chrome)
.PD 0
.TP
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.
.TP
1
@ -259,7 +259,7 @@ The running
.BR pgrep ,
.BR pkill ,
or
.B pwait
.B pidwait
process will never report itself as a
match.
.SH BUGS

22
pgrep.c
View File

@ -38,7 +38,7 @@
#include <stdbool.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/syscall.h>
#endif
@ -87,8 +87,8 @@ enum rel_items {
static enum {
PGREP = 0,
PKILL,
#ifdef ENABLE_PWAIT
PWAIT,
#ifdef ENABLE_PIDWAIT
PIDWAIT,
#endif
} prog_mode;
@ -154,8 +154,8 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
fputs(_(" -<sig>, --signal <sig> signal to send (either number or name)\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);
#ifdef ENABLE_PWAIT
case PWAIT:
#ifdef ENABLE_PIDWAIT
case PIDWAIT:
fputs(_(" -e, --echo display PIDs before waiting\n"), fp);
break;
#endif
@ -698,7 +698,7 @@ static int signal_option(int *argc, char **argv)
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)
{
return syscall(__NR_pidfd_open, pid, flags);
@ -749,8 +749,8 @@ static void parse_opts (int argc, char **argv)
{NULL, 0, NULL, 0}
};
#ifdef ENABLE_PWAIT
if (strcmp (program_invocation_short_name, "pwait") == 0) {
#ifdef ENABLE_PIDWAIT
if (strcmp (program_invocation_short_name, "pidwait") == 0) {
prog_mode = PWAIT;
strcat (opts, "e");
} else
@ -962,7 +962,7 @@ int main (int argc, char **argv)
int num;
int i;
int kill_count = 0;
#ifdef ENABLE_PWAIT
#ifdef ENABLE_PIDWAIT
int poll_count = 0;
int wait_count = 0;
int epollfd = epoll_create(1);
@ -1007,8 +1007,8 @@ int main (int argc, char **argv)
if (opt_count)
fprintf(stdout, "%d\n", num);
return !kill_count;
#ifdef ENABLE_PWAIT
case PWAIT:
#ifdef ENABLE_PIDWAIT
case PIDWAIT:
if (opt_count)
fprintf(stdout, "%d\n", num);

View File