diff options
| author | Karoly Lorentey | 2004-02-08 15:44:33 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-02-08 15:44:33 +0000 |
| commit | 4edd8a5c9030d748c33242e39ac42d4df72a8525 (patch) | |
| tree | 7c05f0bda4d58f71c73c5ae824a5b42c36da3a81 | |
| parent | d743c8f1dbb655051f49f72c3d37484df5a2bea8 (diff) | |
| download | emacs-4edd8a5c9030d748c33242e39ac42d4df72a8525.tar.gz emacs-4edd8a5c9030d748c33242e39ac42d4df72a8525.zip | |
Don't hang on the tty if called from a shell script.
src/sysdep.c (narrow_foreground_group): Set the process group to
inherited_pgroup before calling EMACS_SET_TTY_PGRP. Removed confusing
inherited_pgroup initialization (it is done in emacs.c). (Reported by
Istvan Marko <mi-mtty at kismala dot com>.)
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-75
| -rw-r--r-- | README.multi-tty | 15 | ||||
| -rw-r--r-- | src/sysdep.c | 23 |
2 files changed, 27 insertions, 11 deletions
diff --git a/README.multi-tty b/README.multi-tty index c86d69ac0dd..7e3810e9ff8 100644 --- a/README.multi-tty +++ b/README.multi-tty | |||
| @@ -164,11 +164,11 @@ to the project by testing, bug reports, and suggestions. Thanks! | |||
| 164 | Robert J. Chassel <bob at rattlesnake dot com> | 164 | Robert J. Chassel <bob at rattlesnake dot com> |
| 165 | Romain Francoise <romain at orekobech dot com> | 165 | Romain Francoise <romain at orekobech dot com> |
| 166 | Ami Fischman <ami at fischman dot org> | 166 | Ami Fischman <ami at fischman dot org> |
| 167 | Istvan Marko <mi-mtty ar kismala dot com> | ||
| 167 | Dan Nicolaescu <dann at ics dot uci dot edu> | 168 | Dan Nicolaescu <dann at ics dot uci dot edu> |
| 168 | 169 | ||
| 169 | Richard Stallman was kind enough to review my patches. | 170 | Richard Stallman was kind enough to review my patches. |
| 170 | 171 | ||
| 171 | |||
| 172 | CHANGELOG | 172 | CHANGELOG |
| 173 | --------- | 173 | --------- |
| 174 | 174 | ||
| @@ -176,6 +176,12 @@ See arch logs. | |||
| 176 | 176 | ||
| 177 | THINGS TO DO | 177 | THINGS TO DO |
| 178 | ------------ | 178 | ------------ |
| 179 | |||
| 180 | ** There is a flicker during the startup of `emacs -nw'; it's as if | ||
| 181 | the terminal is initialized, reset and then initialialized again. | ||
| 182 | Debug this. (Hint: narrow_foreground_group is called twice during | ||
| 183 | startup.) | ||
| 184 | |||
| 179 | ** Dan Nicolaescu (dann at ics dot uci dot edu) suggests that -nw | 185 | ** Dan Nicolaescu (dann at ics dot uci dot edu) suggests that -nw |
| 180 | should be added as an alias for -t in emacsclient. Good idea. | 186 | should be added as an alias for -t in emacsclient. Good idea. |
| 181 | (Alas, implementing this is not trivial, getopt_long does not seem | 187 | (Alas, implementing this is not trivial, getopt_long does not seem |
| @@ -649,4 +655,11 @@ DIARY OF CHANGES | |||
| 649 | 655 | ||
| 650 | (Fixed.) | 656 | (Fixed.) |
| 651 | 657 | ||
| 658 | -- Istvan Marko reported that Emacs hang on ttys if it was started | ||
| 659 | from a shell script. | ||
| 660 | |||
| 661 | (Fixed. There was a bug in the multi-tty version of | ||
| 662 | narrow_foreground_group. tcsetpgrp blocks if it is called from a | ||
| 663 | process that is not in the same process group as the tty.) | ||
| 664 | |||
| 652 | ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d | 665 | ;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d |
diff --git a/src/sysdep.c b/src/sysdep.c index 2b7a029b5ba..73b7fb70a99 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1105,24 +1105,27 @@ unrequest_sigio () | |||
| 1105 | the tty's pgroup just like any other terminal setting. If | 1105 | the tty's pgroup just like any other terminal setting. If |
| 1106 | inherited_group was not the tty's pgroup, then we'll get a | 1106 | inherited_group was not the tty's pgroup, then we'll get a |
| 1107 | SIGTTmumble when we try to change the tty's pgroup, and a CONT if | 1107 | SIGTTmumble when we try to change the tty's pgroup, and a CONT if |
| 1108 | it goes foreground in the future, which is what should happen. */ | 1108 | it goes foreground in the future, which is what should happen. |
| 1109 | |||
| 1110 | This variable is initialized in emacs.c. */ | ||
| 1109 | int inherited_pgroup; | 1111 | int inherited_pgroup; |
| 1110 | 1112 | ||
| 1111 | /* Split off the foreground process group to Emacs alone. | 1113 | /* Split off the foreground process group to Emacs alone. When we are |
| 1112 | When we are in the foreground, but not started in our own process | 1114 | in the foreground, but not started in our own process group, |
| 1113 | group, redirect the TTY to point to our own process group. We need | 1115 | redirect the tty device handle FD to point to our own process |
| 1114 | to be in our own process group to receive SIGIO properly. */ | 1116 | group. We need to be in our own process group to receive SIGIO |
| 1117 | properly. */ | ||
| 1115 | void | 1118 | void |
| 1116 | narrow_foreground_group (int fd) | 1119 | narrow_foreground_group (int fd) |
| 1117 | { | 1120 | { |
| 1118 | int me = getpid (); | 1121 | int me = getpid (); |
| 1119 | 1122 | ||
| 1123 | setpgrp (0, inherited_pgroup); | ||
| 1120 | if (! inherited_pgroup) | 1124 | if (! inherited_pgroup) |
| 1121 | inherited_pgroup = getpgid (0); | 1125 | abort (); /* Should not happen. */ |
| 1122 | /* XXX This only works on the controlling tty. */ | ||
| 1123 | if (inherited_pgroup != me) | 1126 | if (inherited_pgroup != me) |
| 1124 | EMACS_SET_TTY_PGRP (fd, &me); | 1127 | EMACS_SET_TTY_PGRP (fd, &me); /* XXX This only works on the controlling tty. */ |
| 1125 | setpgid (0, me); | 1128 | setpgrp (0, me); |
| 1126 | } | 1129 | } |
| 1127 | 1130 | ||
| 1128 | /* Set the tty to our original foreground group. */ | 1131 | /* Set the tty to our original foreground group. */ |
| @@ -1131,7 +1134,7 @@ widen_foreground_group (int fd) | |||
| 1131 | { | 1134 | { |
| 1132 | if (inherited_pgroup != getpid ()) | 1135 | if (inherited_pgroup != getpid ()) |
| 1133 | EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); | 1136 | EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); |
| 1134 | setpgid (0, inherited_pgroup); | 1137 | setpgrp (0, inherited_pgroup); |
| 1135 | } | 1138 | } |
| 1136 | 1139 | ||
| 1137 | #endif /* BSD_PGRPS */ | 1140 | #endif /* BSD_PGRPS */ |