Skip to content

Wait for a (non-child) process' exit using Linux's PROC_EVENTS and POSIX capabilities.

Notifications You must be signed in to change notification settings

stormc/waitforpid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

waitforpid

Wait for a (non-child) process' exit using Linux's PROC_EVENTS. Thanks to the CAP_NET_ADMIN POSIX capability permitted to the waitforpid binary, it does not need to be set suid root.

Installation

You need a Linux kernel having CONFIG_PROC_EVENTS enabled. Clone the repository, compile, and install via

git clone https://github.com/stormc/waitforpid.git
cd waitforpid
make
make install

which installs the binary per default to /usr/local/sbin/waitforpid and sets the required POSIX capability CAP_NET_ADMIN to 'permitted'. DESTDIR and PREFIX parameters to make install are supported.

Usage

waitforpid requires exactly one command line parameter: the PID of the process whose exit is to be waited for. On its exit, waitforpid reports the PID, the exit code, and the signal received by the program it has waited for, in a shell-friendly manner:

> tail -f /dev/null &
  [1] 27080
> waitforpid $! &
  [2] 27082
> fg %1
  [1]  - 27080 running    tail -f /dev/null
> ^C
  PID=27080
  EXITCODE=2
  SIGNAL=17
  [2]  + 27082 done       waitforpid 27080

About

Wait for a (non-child) process' exit using Linux's PROC_EVENTS and POSIX capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published