~ubuntu-branches/ubuntu/hardy/dash/hardy-security

« back to all changes in this revision

Viewing changes to debian/diff/0018-Restore-pgrp-on-exit-fix-backgrounded-MC-bug.diff

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-07-18 15:38:47 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070718153847-pef1uwy72j9gs9pw
Tags: 0.5.4-1ubuntu1
* Merge with Debian; remaining changes:
  - Build against glibc instead of dietlibc
  - Change default answer for "Install dash as /bin/sh?" question to true.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
5
 
 
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.
9
 
 
10
 
Attached patch fixes this. It also fixes another bug: setjobctl(0)
11
 
must ignore tcsetpgrp errors, because there are cases when tty is
12
 
destroyed under dash.
13
 
 
14
 
Patch is run-tested.
15
 
--
16
 
vda
17
 
---
18
 
 src/jobs.c |    5 ++++-
19
 
 src/trap.c |    3 ++-
20
 
 2 files changed, 6 insertions(+), 2 deletions(-)
21
 
 
22
 
diff --git a/src/jobs.c b/src/jobs.c
23
 
index 7285d0d..021640c 100644
24
 
--- a/src/jobs.c
25
 
+++ b/src/jobs.c
26
 
@@ -219,7 +219,10 @@ out:
27
 
                /* turning job control off */
28
 
                fd = ttyfd;
29
 
                pgrp = initialpgrp;
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);
35
 
                setpgid(0, pgrp);
36
 
                setsignal(SIGTSTP);
37
 
                setsignal(SIGTTOU);
38
 
diff --git a/src/trap.c b/src/trap.c
39
 
index eae6186..00e3104 100644
40
 
--- a/src/trap.c
41
 
+++ b/src/trap.c
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)
46
 
-                       _exit(exitstatus);
47
 
+                       status = exitstatus;
48
 
                goto out;
49
 
        }
50
 
        handler = &loc;
51
 
@@ -367,6 +367,7 @@ exitshell(void)
52
 
        }
53
 
        flushall();
54
 
 out:
55
 
+       setjobctl(0);
56
 
        _exit(status);
57
 
        /* NOTREACHED */
58
 
 }
59
 
1.5.2.2
60