Path: utzoo!mnetor!uunet!husc6!bloom-beacon!think!ames!oliveb!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.windows.x Subject: Re: X11 & SHELL PROBLEM Message-ID: <48982@sun.uucp> Date: 10 Apr 88 20:31:24 GMT References: <8804051303.AA03580@ATHENA.MIT.EDU> <1025@daisy.UUCP> Sender: news@sun.uucp Lines: 99 > We have the exact same problem on our sun 386's (RoadRunners). In our case > its caused by the server closing stdin (or so we suspect) on exit, causing > the shell to get ^D's (EOF) and forcing the logout. Try set'ing ignoreeof > to see if that is the case with your users. Nope. 1) If the server closes its standard input on exit, it has no effect whatsoever on the server's parent, i.e. the shell. 2) Even if the C shell's standard input *were* closed by this, this would cause it to get an infinite sequence of EOFs and would (obviously) completely prevent it from reading its standard input. Setting "ignoreeof" wouldn't help. 3) The scenario described by Eduardo Krell is correct (I know, because I'm the one who discovered it). The Xsun server puts its standard output into no-delay mode, so that it won't hang trying to print a message on the console (especially nasty if the console is an "xterm" console window, where in order to display the message Xsun has to paint some bits on the screen...). This also affects the standard input (no matter what version of UNIX you're using; 4BSD-style no-delay mode affects every descriptor that refers to "/dev/console", but even S5-style no-delay mode affects all descriptors "dup"ed from the one changed or from which that one was "dup"ed, so it hits the standard input and error as well). Unfortunately, it doesn't take it *out of* no-delay mode when it exits. The shell then tries to read from the no-delay descriptor and gets an error (or EOF indication, with S5-style no-delay mode). The C shell silently corrects for the former. The Bourne and Korn shells just give up and exit. The C shell's silence is unfortunate; it means that the fact that Xsun was broken wasn't discovered until people not using the C shell tried to run X11. I fixed this on my machine by putting a call to "on_exit" in "server/ddx/sun/sunInit.c" that tells it to call a routine just before exiting; that routine will put the file descriptor back into normal mode. ------- sunInit.c ------- *** /tmp/da9065 Sun Apr 10 13:26:16 1988 --- sunInit.c Mon Mar 7 22:37:31 1988 *************** *** 70,75 **** --- 70,77 ---- int sunSigIO = 0; /* For use with SetInputCheck */ static int autoRepeatHandlersInstalled; /* FALSE each time InitOutput called */ + static int NonBlockConsoleOff(); + /* What should this *really* be? */ #define MOTION_BUFFER_SIZE 0 *************** *** 165,170 **** --- 167,173 ---- * excess of error messages to hang the server in * deadlock. So....... */ + on_exit(NonBlockConsoleOff, (char *)0); if (nonBlockConsole && (fcntl(2, F_SETFL, O_NDELAY) < 0)) { perror("fcntl"); ErrorF("InitOutput: can't put stderr in non-block mode\n"); *************** *** 198,203 **** --- 201,232 ---- sunInitCursor(); signal(SIGWINCH, SIG_IGN); + } + + /*- + *----------------------------------------------------------------------- + * NonBlockConsoleOff -- + * Turn non-blocking mode on the console off, so you don't get logged + * out when Xsun exits. + * + * Results: + * None. + * + * Side Effects: + * None. + * + *----------------------------------------------------------------------- + */ + /*ARGSUSED*/ + static + NonBlockConsoleOff(arg) + char *arg; + { + register int i; + + i = fcntl(2, F_SETFL, O_NDELAY); + if (i >= 0) + (void) fcntl(2, F_SETFL, i & O_NDELAY); } /*-