[st][PATCH] externalpipe sigaction
This patch should be applied on top of the externalpipe patch. It prevents the reset of the signal handler set on SIGCHILD, when the forked process that executes the external process exits. I opted for switching from signal to sigaction instead of rearming the signal in the sigchld function, just because it is the recommended function (although I tried both ways and both worked).
This commit is contained in:
parent
bda5b50b99
commit
5ad2174cf9
3 changed files with 25 additions and 1 deletions
14
st.c
14
st.c
|
|
@ -782,7 +782,11 @@ sigchld(int a)
|
|||
int stat;
|
||||
pid_t p;
|
||||
|
||||
#if EXTERNALPIPE_SIGACTION_PATCH && EXTERNALPIPE_PATCH
|
||||
if ((p = waitpid(-1, &stat, WNOHANG)) < 0)
|
||||
#else
|
||||
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
||||
#endif // EXTERNALPIPE_SIGACTION_PATCH
|
||||
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
||||
|
||||
if (pid != p)
|
||||
|
|
@ -823,6 +827,9 @@ int
|
|||
ttynew(char *line, char *cmd, char *out, char **args)
|
||||
{
|
||||
int m, s;
|
||||
#if EXTERNALPIPE_SIGACTION_PATCH && EXTERNALPIPE_PATCH
|
||||
struct sigaction sa;
|
||||
#endif // EXTERNALPIPE_SIGACTION_PATCH
|
||||
|
||||
if (out) {
|
||||
term.mode |= MODE_PRINT;
|
||||
|
|
@ -878,7 +885,14 @@ ttynew(char *line, char *cmd, char *out, char **args)
|
|||
#endif
|
||||
close(s);
|
||||
cmdfd = m;
|
||||
#if EXTERNALPIPE_SIGACTION_PATCH && EXTERNALPIPE_PATCH
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_handler = sigchld;
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
#else
|
||||
signal(SIGCHLD, sigchld);
|
||||
#endif // EXTERNALPIPE_SIGACTION_PATCH
|
||||
break;
|
||||
}
|
||||
return cmdfd;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue