Signals and zombie processes

29 views
Skip to first unread message

Rick Taft

unread,
Apr 8, 2020, 1:47:14 PM4/8/20
to klish
Having a problem with zombie processes. When a user kills a terminal window that's running a KLISH action, the entire process tree remains running as a zombie. I found code in clish/shell-execute.c and the following comment:

/* Ignore and block SIGINT, SIGQUIT, SIGHUP.
* The SIG_IGN is not a case because it will be inherited
* while a fork(). It's necessary to ignore signals because
* the klish itself and ACTION script share the same terminal.
*/

Is there anything I can do about this besides just killing the zombies after the fact?
Can I comment out the code that blocks the signals or is that going to lead to a lot of other problems?

Any help would be greatly appreciated!

Serj Kalichev

unread,
Apr 13, 2020, 3:54:11 AM4/13/20
to kl...@googlegroups.com
The full code block is:

<------>/* Ignore and block SIGINT, SIGQUIT, SIGHUP.
<------> * The SIG_IGN is not a case because it will be inherited
<------> * while a fork(). It's necessary to ignore signals because
<------> * the klish itself and ACTION script share the same terminal.
<------> */
<------>sa.sa_flags = 0;
<------>sigemptyset(&sa.sa_mask);
<------>sa.sa_handler = sigignore; /* Empty signal handler */
<------>sigaction(SIGINT, &sa, &old_sigint);
<------>sigaction(SIGQUIT, &sa, &old_sigquit);
<------>sigaction(SIGHUP, &sa, &old_sighup);
<------>/* Block signals for children processes. The block state is inherited. */
<------>if (!intr) {
<------><------>sigset_t sigs;
<------><------>sigemptyset(&sigs);
<------><------>sigaddset(&sigs, SIGINT);
<------><------>sigaddset(&sigs, SIGQUIT);
<------><------>sigaddset(&sigs, SIGHUP);
<------><------>sigprocmask(SIG_BLOCK, &sigs, &old_sigs);
<------>}

The signals redefined by sigaction() are inherited by fork() but not inherited by execve() (exclude SIG_IGN values).
So the first part of code block is about klish itself but not for executed processes.
The signal blocking is inhereted by execve(). So the second part of code block is for the executed processes. But note the condition (!intr). It says that commands with <COMMAND interrupt="true" ...> will not be blocked. May be you need an 'interrupt="true"' field.

If you already have interrupt="true" then probably your problem is shell signal handling. Try the same operations without klish.





08.04.2020 20:47, Rick Taft пишет:
--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/klish/6b648c48-7754-4b93-8c5b-1ee60a012242%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages