ralphlange / procServ

Wrapper to start arbitrary interactive commands in the background, with telnet or Unix domain socket access to stdin/stdout
GNU General Public License v3.0
23 stars 23 forks source link

child process cannot be terminated with SIGTERM #48

Open dirk-zimoch opened 3 years ago

dirk-zimoch commented 3 years ago

Since V6.6.1, to be exact since commit 291c7a08b342e6df134d40bd996543fd41fd1a5f "Make signal handling safe using pselect.", the child process started by procServ cannot be terminated with SIGTERM any longer. In particular --killsig 15 does not work.

The reason is probably that the child inherits the signal mask which blocks SIGTERM (and SIGPIPE and SIGHUP).

Signal mask should be reset to "normal" for the child.

ralphlange commented 3 years ago

+1

dirk-zimoch commented 3 years ago

man sigprocmask:

A child created via fork(2) inherits a copy of its parent's signal mask; the signal mask is preserved across execve(2).

dirk-zimoch commented 3 years ago

Argh, only half the job... Need to handle SIG_IGN as well.

dirk-zimoch commented 3 years ago

I replaced ignoring signals by blocking signals so that signals can be restored easier in the child process.

dirk-zimoch commented 3 years ago

Should I put the fix for the annoying SigPipe message #43 into this branch, too?

I would also like to clean up spaces and tabs.