1
From 5183d5dffe1bc6f56eaa0a1d26ba59a10aa3456b Mon Sep 17 00:00:00 2001
2
From: Denis Vlasenko <vda.linux@googlemail.com>
3
Date: Tue, 26 Jun 2007 13:05:08 +0000
4
Subject: [PATCH] Restore pgrp on exit (fix "backgrounded MC" bug)
6
When I start dash under Midnight Commander and then type 'exit', dash
7
exits all right, but then MC is sent to background. It happens because
8
dash does not restore current process group on exit.
10
Attached patch fixes this. It also fixes another bug: setjobctl(0)
11
must ignore tcsetpgrp errors, because there are cases when tty is
20
2 files changed, 6 insertions(+), 2 deletions(-)
22
diff --git a/src/jobs.c b/src/jobs.c
23
index 7285d0d..021640c 100644
26
@@ -219,7 +219,10 @@ out:
27
/* turning job control off */
30
- xtcsetpgrp(fd, pgrp);
31
+ /* was xtcsetpgrp, but this is used on exit and
32
+ * can loop forever if tty is already destroyed
33
+ * (e.g. broken ssh link, closed xterm etc) */
34
+ tcsetpgrp(fd, pgrp);
38
diff --git a/src/trap.c b/src/trap.c
39
index eae6186..00e3104 100644
42
@@ -357,7 +357,7 @@ exitshell(void)
43
TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
44
if (setjmp(loc.loc)) {
45
if (exception == EXEXIT)
47
+ status = exitstatus;
51
@@ -367,6 +367,7 @@ exitshell(void)