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>
This commit is contained in:
Joerg Wunsch 1999-03-02 19:08:09 +00:00
parent 37cd370c97
commit d7a28702a3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44431
2 changed files with 3 additions and 2 deletions

View file

@ -314,6 +314,7 @@ wwinit()
wwerrno = WWE_SYS; wwerrno = WWE_SYS;
goto bad; goto bad;
} }
fcntl(0,F_SETOWN,getpid());
/* catch typeahead before ASYNC was set */ /* catch typeahead before ASYNC was set */
(void) kill(getpid(), SIGIO); (void) kill(getpid(), SIGIO);
wwstart1(); wwstart1();

View file

@ -42,7 +42,7 @@ static char sccsid[] = "@(#)wwspawn.c 8.1 (Berkeley) 6/6/93";
#include <signal.h> #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. * So we have to be sneaky about error reporting.
*/ */
wwspawn(wp, file, argv) wwspawn(wp, file, argv)
@ -56,7 +56,7 @@ char **argv;
int s; int s;
s = sigblock(sigmask(SIGCHLD)); s = sigblock(sigmask(SIGCHLD));
switch (pid = fork()) { switch (pid = vfork()) {
case -1: case -1:
wwerrno = WWE_SYS; wwerrno = WWE_SYS;
ret = -1; ret = -1;