summaryrefslogtreecommitdiffstats
path: root/usr.bin/window
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1999-03-02 19:08:09 +0000
committerjoerg <joerg@FreeBSD.org>1999-03-02 19:08:09 +0000
commit1288f941f795b1d583b25811de62109336d75b26 (patch)
tree3015fa43a3c326ec194d5d0bd8223916caf39a62 /usr.bin/window
parentc58977479e272849c1164815ed8e7706b6a47a6f (diff)
downloadFreeBSD-src-1288f941f795b1d583b25811de62109336d75b26.zip
FreeBSD-src-1288f941f795b1d583b25811de62109336d75b26.tar.gz
Make window(1) actually work again. It has been broken for quite some
time now. For whatever reason, the kernel seems to have generated SIGIOs previously without an initial fcntl(...,F_SETOWN), but does no longer. This caused window(1) to wait indefinitely for input. Also, undo rev 1.3 of wwspawn.c, it was not well-thought, and apparently not even tested at all. The blindly (even in a nonsensical place like the comment on top of the function) applied replacement of vfork() by fork() totally ignored that window(1) *does* abuse the feature of vfork() where a modification of the parent's address space is possible (in this case, to notify the parent of an erred exec*). Also, with vfork(), it is guaranteed that the parent is only woken up after the exec*() happened, where the replacement by fork() made the parent to almost always become runnable again before the child, in which case the parent simply told `subprocess died'. Unfortunately, working around _this_ seems to be a lot more of redesign work compared to little gained value, so i think relying on the specifics of vfork() is the simpler way. Submitted by: Philipp Mergenthaler <un1i@rz.uni-karlsruhe.de>
Diffstat (limited to 'usr.bin/window')
-rw-r--r--usr.bin/window/wwinit.c1
-rw-r--r--usr.bin/window/wwspawn.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/window/wwinit.c b/usr.bin/window/wwinit.c
index 0747319..b22eaf9 100644
--- a/usr.bin/window/wwinit.c
+++ b/usr.bin/window/wwinit.c
@@ -314,6 +314,7 @@ wwinit()
wwerrno = WWE_SYS;
goto bad;
}
+ fcntl(0,F_SETOWN,getpid());
/* catch typeahead before ASYNC was set */
(void) kill(getpid(), SIGIO);
wwstart1();
diff --git a/usr.bin/window/wwspawn.c b/usr.bin/window/wwspawn.c
index 3588dd8..57e2f66 100644
--- a/usr.bin/window/wwspawn.c
+++ b/usr.bin/window/wwspawn.c
@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)wwspawn.c 8.1 (Berkeley) 6/6/93";
#include <signal.h>
/*
- * There is a dead lock with fork and closing of pseudo-ports.
+ * There is a dead lock with vfork and closing of pseudo-ports.
* So we have to be sneaky about error reporting.
*/
wwspawn(wp, file, argv)
@@ -56,7 +56,7 @@ char **argv;
int s;
s = sigblock(sigmask(SIGCHLD));
- switch (pid = fork()) {
+ switch (pid = vfork()) {
case -1:
wwerrno = WWE_SYS;
ret = -1;
OpenPOWER on IntegriCloud