jk would like you to merge 1 commits from /u/joerg-krause/upmpdcli/ to master
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.
Discussion
-
jk
2018-05-16Can you tell me the reason why you rejected this commit?
-
medoc
2018-05-16Oops, sorry, I had commented, but this got lost somehow.
There are 2 problems with your change (except if I did not read well):
- it busy-loops
- if the child program is ill-behaved (does not exit), the parent is stuck forever.
I am preparing another change to enable configuring the grace period before SIGKILL is sent. So we can add an upmpdcli parameter to adjust this to taste.