Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@earthlink.net>
Subject: Re: unix process behaviour when terminal windows get killed?
Date: Tue, 08 Oct 2002 07:04:47 GMT	[thread overview]
Message-ID: <m3u1jxtq7u.fsf@salmon.parasoft.com> (raw)
In-Reply-To: 20021007202851.28570.00000238@mb-bh.aol.com

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.


  reply	other threads:[~2002-10-08  7:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-08  0:28 unix process behaviour when terminal windows get killed? Williamcin
2002-10-08  7:04 ` Paul Pluzhnikov [this message]
2002-10-08 11:51 ` Thomas Dickey
2002-10-11  3:00   ` Williamcin
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox