pgrep: Better warning if pidfd_open not implemented
If procps is built on a Linux 5.3+ system then pidwait is built with pidfd_open(). If that program is run on a system < 5.3 then it gives an odd generic error. If we get a ENOSYS from one pid, we will get it for all the others so its better to explain what happens and terminate. The man page is updated to note this issue. This came up due to killall in psmisc using pidfd_send_signal References: https://bugs.debian.org/1015228 Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit is contained in:
parent
bcce3e440a
commit
95a253aa6e
1
NEWS
1
NEWS
@ -2,6 +2,7 @@ procps-ng-NEXT
|
|||||||
* library
|
* library
|
||||||
Re-add elogind support merge #151
|
Re-add elogind support merge #151
|
||||||
Used memory is Total - Available
|
Used memory is Total - Available
|
||||||
|
* pidwait: Better warning if pidfd_open not implemented
|
||||||
* pmap: Dont reuse stdin filehandle issue #231
|
* pmap: Dont reuse stdin filehandle issue #231
|
||||||
* ps: threads again display when -L is used with -q issue #234
|
* ps: threads again display when -L is used with -q issue #234
|
||||||
* ps: proper aix format string behavior was restored
|
* ps: proper aix format string behavior was restored
|
||||||
|
8
pgrep.1
8
pgrep.1
@ -7,7 +7,7 @@
|
|||||||
.\" the Free Software Foundation; either version 2 of the License, or
|
.\" the Free Software Foundation; either version 2 of the License, or
|
||||||
.\" (at your option) any later version.
|
.\" (at your option) any later version.
|
||||||
.\"
|
.\"
|
||||||
.TH PGREP "1" "2021-12-25" "procps-ng" "User Commands"
|
.TH PGREP "1" "2022-07-18" "procps-ng" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pgrep, pkill, pidwait \- 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
|
||||||
@ -281,7 +281,11 @@ can not be combined. Let
|
|||||||
me know if you need to do this.
|
me know if you need to do this.
|
||||||
.PP
|
.PP
|
||||||
Defunct processes are reported.
|
Defunct processes are reported.
|
||||||
|
.PP
|
||||||
|
.B pidwait
|
||||||
|
requires the
|
||||||
|
.BR pidfd_open (2)
|
||||||
|
system call which first appeared in Linux 5.3.
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.BR ps (1),
|
.BR ps (1),
|
||||||
.BR regex (7),
|
.BR regex (7),
|
||||||
|
2
pgrep.c
2
pgrep.c
@ -1064,6 +1064,8 @@ int main (int argc, char **argv)
|
|||||||
printf(_("waiting for %s (pid %lu)\n"), procs[i].str, procs[i].num);
|
printf(_("waiting for %s (pid %lu)\n"), procs[i].str, procs[i].num);
|
||||||
int pidfd = pidfd_open(procs[i].num, 0);
|
int pidfd = pidfd_open(procs[i].num, 0);
|
||||||
if (pidfd == -1) {
|
if (pidfd == -1) {
|
||||||
|
if (errno == ENOSYS)
|
||||||
|
xerrx(EXIT_FAILURE, _("pidfd_open() not implemented in Linux < 5.3"));
|
||||||
/* ignore ESRCH, same as pkill */
|
/* ignore ESRCH, same as pkill */
|
||||||
if (errno != ESRCH)
|
if (errno != ESRCH)
|
||||||
xwarn(_("opening pid %ld failed"), procs[i].num);
|
xwarn(_("opening pid %ld failed"), procs[i].num);
|
||||||
|
Loading…
Reference in New Issue
Block a user