pidwait - suboptimal support for matching specific pids
My use case is using pidwait in a ExecStop in a systemd unit.
What I'd like to do is something like this:
ExecStop=<command to shutdown service>
ExecStop=pidwait $MAINPID
But pidwait tries to match $MAINPID as a process name, not a process id. As far as I can tell from reading the manage, there is no way to instruct pidwait to interpret the supplied arguments as process ids and not process names.
My second attempt was to use pidwait's -F option, like this:
ExecStop=<command to shutdown service>
ExecStop=bash -c "echo $MAINPID | pidwait -F /dev/stdin"
But this failed because pidwait checks whether the pidfile is a regular file.
In the end, I changed my ExecStop command to be a shell script that wrote $MAINPID to a temporary file. But that seems like a lot of complexity for what should be a simple action.
Ideally pidwait would support both specifying specific pids and reading pids from a pipe.
Edited by J.T. Conklin