From 80bb4b8ab7db1044d16b6e76ac5ca9ef2c13f12b Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 15 May 2021 11:44:09 +0200 Subject: [PATCH] externalpipe: sigchld changes interfere with right-click-to-plumb and opencopied patches, proposed fix ref. #27 --- patch/externalpipe.c | 3 +++ st.c | 6 +++++- st.h | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/patch/externalpipe.c b/patch/externalpipe.c index a4c4cb9..37d8848 100644 --- a/patch/externalpipe.c +++ b/patch/externalpipe.c @@ -1,3 +1,5 @@ +int extpipeactive = 0; + void #if EXTERNALPIPEIN_PATCH extpipe(const Arg *arg, int in) @@ -58,6 +60,7 @@ externalpipe(const Arg *arg) close(to[1]); /* restore */ signal(SIGPIPE, oldsigpipe); + extpipeactive = 1; } #if EXTERNALPIPEIN_PATCH diff --git a/st.c b/st.c index d35f134..b4d5b33 100644 --- a/st.c +++ b/st.c @@ -977,7 +977,7 @@ sigchld(int a) pid_t p; #if EXTERNALPIPEIN_PATCH && EXTERNALPIPE_PATCH - if ((p = waitpid(-1, &stat, WNOHANG)) < 0) + if ((p = waitpid((extpipeactive ? -1 : pid), &stat, WNOHANG)) < 0) #else if ((p = waitpid(pid, &stat, WNOHANG)) < 0) #endif // EXTERNALPIPEIN_PATCH @@ -985,11 +985,15 @@ sigchld(int a) #if EXTERNALPIPE_PATCH if (pid != p) { + if (!extpipeactive) + return; + if (p == 0 && wait(&stat) < 0) die("wait: %s\n", strerror(errno)); /* reinstall sigchld handler */ signal(SIGCHLD, sigchld); + extpipeactive = 0; return; } #else diff --git a/st.h b/st.h index 92db4c9..697de9c 100644 --- a/st.h +++ b/st.h @@ -345,6 +345,10 @@ extern unsigned int tabspaces; extern unsigned int defaultfg; extern unsigned int defaultbg; extern unsigned int defaultcs; +#if EXTERNALPIPE_PATCH +extern int extpipeactive; +#endif // EXTERNALPIPE_PATCH + #if BOXDRAW_PATCH extern const int boxdraw, boxdraw_bold, boxdraw_braille; #endif // BOXDRAW_PATCH