Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!mentor.cc.purdue.edu!noose.ecn.purdue.edu!newton.physics.purdue.edu!sawmill!sawmill!rjk From: rjk@sawmill.sawmill.uucp (Richard Kuhns) Newsgroups: comp.unix.wizards Subject: Re: Phantom CPU gobbler?! Message-ID: Date: 9 Jul 90 21:28:17 GMT References: <960004@teecs.UUCP> <1277@tuewsd.win.tue.nl> Sender: news@sawmill.uucp (News Administration) Organization: Grauel Enterprises Lines: 56 In article <1277@tuewsd.win.tue.nl> wsinpdb@lso.win.tue.nl (Paul de Bra) writes: Sender: wsinpdb@win.tue.nl (Paul de Bra) Organization: Eindhoven University of Technology, The Netherlands Lines: 15 In article <960004@teecs.UUCP> belkin@teecs.UUCP (Hershel Belkin) writes: >... >Every so often I fins a shell process (sh or ksh) which has somehow >become dis-associated with its logon session. By this I mean that >the shell's PPID is "1", and the user is no longer logged on. >... This is the infamous trap/signal/eof bug, which I don't know exactly, but some combination of trapping and sending signals and having end-of-file on standard input causes an infinite loop in the Bourne and Korn shell, at least in some Unix versions which haven't fixed the bug. Anyone know the full scoop? Paul. I don't know if this is the *full* scoop or not, but some versions of Korn shell and Bourne shell have problems if a program leaves the terminal (stdin) in non-blocking mode when you've set `ignoreeof'. The following little program will exercise this bug, if that's what it is. Rich Kuhns newton.physics.purdue.edu!sawmill!rjk ==============================cut here============================== /* killksh.c */ #include #include extern int errno; main(argc, argv) int argc; char *argv[]; { char *progname; int flags; progname = *argv; if ((flags = fcntl(0, F_GETFL, 0)) < 0) { fprintf(stderr, "%s:can't get flags (errno=%d)\n", progname); exit(1); } if (fcntl(0, F_SETFL, flags|O_NDELAY) < 0) { fprintf(stderr, "%s:can't set flags (errno=%d)\n", progname, errno); exit(1); } fprintf(stderr, "shell should crash in 3 seconds\n"); sleep(3); exit(0); }