Execute a loop that monitors the child process and use the W*() macros
to analyze the wait status value.
This fixes an issue where the child process' SIGTERM handler takes more time
to handle the SIGTERM signal than the parent process is currently waiting for
the child process to terminate.
For example, if a custom scsenderpath
script is used which defines a
sigterm handler. Lets assume the sigterm handling takes 10 seconds.
After sending the TERM signal, upmpdcli waits about two seconds before
sending a KILL signal to finally terminate the process:
Tested with running upmpdcli in daemon mode and running scctl:
scctl -I hostname
"PL-to-Songcast"
scctl -x hostname
Before this commit:
:4:src/execmd-fixed.cpp:276::ExecCmd: pid 9662 killpg(9662, SIGTERM)
:4:mpd2src/mpd2sc.cpp:83::sigcatcher
:4:mpd2src/mpd2sc.cpp:667::Main: cleaning up
:4:src/execmd-fixed.cpp:287::ExecCmd: killpg(9662, SIGKILL)
New behavior:
:4:src/execmd-fixed.cpp:276::ExecCmd: pid 9886 killpg(9886, SIGTERM)
:4:mpd2src/mpd2sc.cpp:83::sigcatcher
:4:mpd2src/mpd2sc.cpp:667::Main: cleaning up
:4:src/execmd-fixed.cpp:291::ExecCmd: 9886 exited, status=0
Now, upmpdcli waits until the child process is terminated.
Signed-off-by: Jörg Krause joerg.krause@embedded.rocks