diff --git a/README.md b/README.md index 3d7c975..0be99ab 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: -2020-04-20 - Added the force redraw on pselect after key is pressed patch +2020-04-20 - Added the force redraw on pselect after key is pressed patch and the externalpipe sigaction patch 2020-03-29 - Added invert and workingdir patches @@ -60,6 +60,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [externalpipe](https://st.suckless.org/patches/externalpipe/) - this patch allows for eading and writing st's screen through a pipe, e.g. to pass info to dmenu + - [externalpipe-sigaction](https://lists.suckless.org/hackers/2004/17216.html) + - this patch prevents the reset of the signal handler set on SIGCHILD, when the forked process that executes the external process exits + - [~fixime~](https://st.suckless.org/patches/fix_ime/) - adds better Input Method Editor (IME) support - (included in the base as per [35f7db](https://git.suckless.org/st/commit/e85b6b64660214121164ea97fb098eaa4935f7db.html)) diff --git a/patches.def.h b/patches.def.h index 5d1acb5..6638330 100644 --- a/patches.def.h +++ b/patches.def.h @@ -68,6 +68,13 @@ */ #define EXTERNALPIPE_PATCH 0 +/* This patch prevents the reset of the signal handler set on SIGCHILD, when + * the forked process that executes the external process exits. + * This patch depends on EXTERNALPIPE_PATCH being enabled. + * https://lists.suckless.org/hackers/2004/17216.html + */ +#define EXTERNALPIPE_SIGACTION_PATCH 0 + /* This patch allows command line applications to use all the fancy key combinations * that are available to GUI applications. * https://st.suckless.org/patches/fix_keyboard_input/ diff --git a/st.c b/st.c index 1a1aea1..779886c 100644 --- a/st.c +++ b/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;