km@emory.uucp (Ken Mandelberg) (09/24/87)
I have been having problems terminating X11 on my Sun 3/50. I start it from my login shell on the console with "xinit xterm", and terminate by exiting the xterm. I get a message to the console from xinit telling me that it is killing the server. I then see my login shell die, a getty appear, and getty complain about not being able to read. I am unable to log back in on the console (no input echos). When I try a "stty everything </dev/console " from another terminal it looks sane. If I try a "cat </dev/console", cat aborts saying that the read would block. Presumably what is happening is that the console is being left in a state where "read" returns "-1" continually with an errno of "EWOULDBLOCK". The shell dies and the getty complains because of this. I have read the README in server/sun directory. "kbd_mode -a" does no good. Presumably, I should not even need it since I am terminating X normally, not abnormally. So far I have found no cure except to reboot, although I have not tried very much yet. I am running SunOS 3.4 on a Sun3/50 which is one of the tested configurations. Any suggestions? -- Ken Mandelberg | gatech!emory!km USENET Emory University | km@emory CSNET,BITNET Dept of Math and CS | km.emory@csnet-relay ARPANET Atlanta, Ga 30322 | Phone: (404) 727-7963
km@emory.uucp (Ken Mandelberg) (09/25/87)
I previously reported that "xinit xterm" for X11 on a Sun caused my shell to die and getty to go mad, on a normal termination. The problem was not the kbd_mode issue involved in an abnormal terminiation. The problem turns out to be my shell. I use ksh, but the same problem would occur in /bin/sh. Xsun sets FNDELAY via fcntl, and no one restored it on normal termination. This is not a problem for /bin/csh which dup's the orginal terminal fd's up to high fd numbers, and dup's them back when recovering the terminal. ksh and sh don't do that. My solution is a modification of xinit to save and restore the fcntl status flag. A diff follows: *** xinit.c Thu Sep 24 23:14:13 1987 --- xinit.c.orig Thu Sep 24 23:10:41 1987 *************** *** 13,19 **** #include <sys/resource.h> #include <sys/wait.h> #include <errno.h> - #include <fcntl.h> #define TRUE 1 #define FALSE 0 --- 13,18 ---- *************** *** 36,42 **** int serverpid = -1; int clientpid = -1; extern int errno; - int flag; /*save fcntl flag */ sigCatch(sig) int sig; --- 35,40 ---- *************** *** 45,51 **** signal(SIGINT, SIG_IGN); Error("signal %d\n", sig); shutdown(serverpid, clientpid); ! exitt(1); } main(argc, argv) --- 43,49 ---- signal(SIGINT, SIG_IGN); Error("signal %d\n", sig); shutdown(serverpid, clientpid); ! exit(1); } main(argc, argv) *************** *** 93,100 **** *sptr++ = *argv++; *sptr = NULL; - fcntl(2,F_GETFL,&flag); - /* * Start the server and client. */ --- 91,96 ---- *************** *** 112,119 **** shutdown(serverpid, clientpid); if (serverpid < 0 || clientpid < 0) ! exitt(ERR_EXIT); ! exitt(OK_EXIT); } --- 108,115 ---- shutdown(serverpid, clientpid); if (serverpid < 0 || clientpid < 0) ! exit(ERR_EXIT); ! exit(OK_EXIT); } *************** *** 187,193 **** char *fmt; { Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); ! exitt(ERR_EXIT); } startServer(server) --- 183,189 ---- char *fmt; { Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); ! exit(ERR_EXIT); } startServer(server) *************** *** 290,300 **** if (processTimeout(serverpid, 3, "server to die")) Fatal("Can't kill server\n"); } - exitt(i) - int i; - - { - fcntl(2, F_SETFL,flag); - exit(i); - } - --- 286,288 ---- -- Ken Mandelberg | gatech!emory!km USENET Emory University | km@emory CSNET,BITNET Dept of Math and CS | km.emory@csnet-relay ARPANET Atlanta, Ga 30322 | Phone: (404) 727-7963