From d7a28702a3a8748d9b72416e9f14cca98db8af88 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Tue, 2 Mar 1999 19:08:09 +0000 Subject: [PATCH] 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 --- usr.bin/window/wwinit.c | 1 + usr.bin/window/wwspawn.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/window/wwinit.c b/usr.bin/window/wwinit.c index 074731984f13..b22eaf9bf325 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 3588dd88150c..57e2f666ef62 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 /* - * 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;