summaryrefslogtreecommitdiff
blob: 701d087c784cfa18fad35dc6abb9ae010c91b023 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
zsh and pid namespaces don't play very well together.  Specifically, when zsh is
launched inside a new pid namespace, it doesn't take ownership of the process
group, causing things like SIGINT to be sent to the parent process.  Upstream
bug report here: http://www.zsh.org/mla/workers/2014/msg01769.html.

The first chunk of this diff fixes this problem and has already been applied
upstream:
https://sourceforge.net/p/zsh/code/ci/0c4cb0cc1b527f4341f1a39a10f4120aa7c7d594/.

The second chunk is a suggested fix for the warning that zsh prints when
exiting: http://www.zsh.org/mla/workers/2014/msg01779.html.

diff --git a/Src/jobs.c b/Src/jobs.c
index a668b07..c6e1bce 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2734,7 +2734,7 @@ acquire_pgrp(void)
     long ttpgrp;
     sigset_t blockset, oldset;
 
-    if ((mypgrp = GETPGRP()) > 0) {
+    if ((mypgrp = GETPGRP()) >= 0) {
 	long lastpgrp = mypgrp;
 	sigemptyset(&blockset);
 	sigaddset(&blockset, SIGTTIN);
@@ -2779,8 +2779,11 @@ void
 release_pgrp(void)
 {
     if (origpgrp != mypgrp) {
-	attachtty(origpgrp);
-	setpgrp(0, origpgrp);
+	/* in linux pid namespaces, origpgrp may never have been set */
+	if (origpgrp) {
+	    attachtty(origpgrp);
+	    setpgrp(0, origpgrp);
+	}
 	mypgrp = origpgrp;
     }
 }