From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,77fbcb0bbe1b980b X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 2002-10-08 00:10:02 PST Path: archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!telocity-west!TELOCITY!newsfeed-west.nntpserver.com!hub1.meganetnews.com!nntpserver.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp2.aus1.giganews.com!nntp.giganews.com!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Newsgroups: comp.unix.osf.osf1 Subject: Re: unix process behaviour when terminal windows get killed? References: <20021007202851.28570.00000238@mb-bh.aol.com> From: Paul Pluzhnikov Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 08 Oct 2002 07:04:47 GMT NNTP-Posting-Host: 24.205.84.44 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1034060687 24.205.84.44 (Tue, 08 Oct 2002 00:04:47 PDT) NNTP-Posting-Date: Tue, 08 Oct 2002 00:04:47 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.unix.osf.osf1:139 williamcin@aol.com (Williamcin) writes: > During the day, we use the terminal emulator (both native MS telnet and > TeraTerm) from our PC to connect to our Tru64 Unix 5.1A system and run a > character-based in-house application. > > Everything runs ok until the end of the day when people finished their work and > some people just kill the terminal windows by clicking the "X" on the top right > hand corner of the window. Most of the time, killing the windows like that will > kill the Unix process as well (I have assumed that a 'kill -9' signal is sent > over to the Unix and kill that process) Usually it is SIGTERM that is being sent -- this way the app can can clean up (e.g. remove any lock files) before exiting. > but sometimes the Unix process attached > to that terminal will go into infinite loop and use 99.9% of the CPU. We have > to kill that process manually (takes a look time) to get the system back. The most likely explanation for this is that the in-hous app does not handle EOF correctly (application bug). Another possibility is that the user didn't actually use the "X", but instead switched the whole PC off (without a proper shutdown). > 1. exactly what would happen to the Unix process when someone just kill the > terminal windows by clicking the "X" All processes for which this terminal window is a controlling terminal are supposed to receive SIGTERM. Subsequent attempts to read(2) from stdin result in EOF. > 2. is there a way for software (our in-house application) to detect this kind > of situation so that when it happen, it can kill itself? Sure. Just fix the bug in EOF handling ;-) One common bug is this: char ch; /* should be int */ while ((ch = getch()) != EOF) /* condition always false */ handle(ch); Cheers, -- In order to understand recursion you must first understand recursion.