[comp.unix.wizards] killing bkgnd process on logout

bmw@isgtec.UUCP (Bruce Walker) (08/31/89)

In article <92@harald.UUCP> jba@harald.ruc.dk (Jan B. Andersen) writes:
>>In article <128@isgtec.UUCP> bmw@isgtec.UUCP (Bruce Walker) writes:
>>[ in BSD systems ]
>>the process
>>disconnects from your tty and continues running ...
>
>This has nothing to do with BSD vs Sys V.
>
>        [CSH man page excerpt deleted]

Well, it sort-of does.  Csh's under SysV are usually sub-sets of full-blown
BSD csh's, and don't behave the same.

I am using csh as implimented by Convergent Technologies' CTIX (essentially
SysV) and csh as implimented by Sun (4.0.1).

If I run my checkmail process in the background from CTIX csh, then log out,
checkmail dies.  If I do that on Sun csh, it behaves as your man page
suggests (ignores SIGHUP).  I suspect that other SysV csh's also behave more
like sh(1) than BSD csh in this regard.
-- 
Bruce Walker                          ...uunet!mnetor!lsuc!isgtec!bmw
"Better Living Through Connectivity"         ...utzoo!lsuc!isgtec!bmw
ISG Technologies Inc. 3030 Orlando Dr. Mississauga. Ont. Can. L4V 1S8

jba@harald.ruc.dk (Jan B. Andersen) (09/01/89)

bmw@isgtec.UUCP (Bruce Walker) writes:

-In article <92@harald.UUCP> jba@harald.ruc.dk (Jan B. Andersen) writes:
->>In article <128@isgtec.UUCP> bmw@isgtec.UUCP (Bruce Walker) writes:
->>[ in BSD systems ]
->>the process disconnects from your tty and continues running ...
->
->This has nothing to do with BSD vs Sys V.
->
->        [CSH man page excerpt deleted]

-Well, it sort-of does.  Csh's under SysV are usually sub-sets of full-blown
-BSD csh's, and don't behave the same.

-If I run my checkmail process in the background from CTIX csh, then log out,
-checkmail dies.  If I do that on Sun csh, it behaves as your man page
-suggests (ignores SIGHUP).  I suspect that other SysV csh's also behave more
-like sh(1) than BSD csh in this regard.

The man page I quoted was from a NCR Tower running some sort of System V
(it definitly isn't BSD). Although I would prefer it to behave like the
sh(1) I would much more prefer _every_ csh(1) to behave exactly the same.
And that means behave like a genuie BSD csh.

-Bruce Walker                          ...uunet!mnetor!lsuc!isgtec!bmw

Sorry for all this quoting, but I found it nescessary.

jwc@unify.UUCP (J. William ) (09/02/89)

In article <130@isgtec.UUCP> bmw@isgtec.UUCP (Bruce Walker) writes:
> [...]
>If I run my checkmail process in the background from CTIX csh, then log out,
>checkmail dies.  If I do that on Sun csh, it behaves as your man page
>suggests (ignores SIGHUP).  I suspect that other SysV csh's also behave more
>like sh(1) than BSD csh in this regard.

I suspect that when checkmail is not ignoring SIGHUP.  Rather, BSD csh
puts each background job into a separate process group to facilitate
job control.  Only the process group currently in the forground is
attached to the controlling terminal.
-- 

Bill Claypool    W. (916) 920-9092 | I know what I know if you know what I mean
jwc@unify.UUCP   H. (916) 381-4205 |-------------------------------------------
    ...!{csusac,pyramid}!unify!jwc |      SCCA SFR Solo II 74 es '84 CRX

allbery@NCoast.ORG (Brandon S. Allbery) (09/03/89)

As quoted from <130@isgtec.UUCP> by bmw@isgtec.UUCP (Bruce Walker):
+---------------
| In article <92@harald.UUCP> jba@harald.ruc.dk (Jan B. Andersen) writes:
| >>In article <128@isgtec.UUCP> bmw@isgtec.UUCP (Bruce Walker) writes:
| >>[ in BSD systems ]
| >>the process
| >>disconnects from your tty and continues running ...
| >
| >This has nothing to do with BSD vs Sys V.
| 
| Well, it sort-of does.  Csh's under SysV are usually sub-sets of full-blown
| BSD csh's, and don't behave the same.
+---------------

Sorry, it's a BSD-vs.-Sys5 issue.  csh doesn't act the same under System V
because System V doesn't handle process groups the same way BSD does.  BSD
process groups are used to implement job control; this is why a backgrounded
process in a job-control environment (like csh) detaches from the terminal.

++Brandon
-- 
Brandon S. Allbery, moderator of comp.sources.misc	     allbery@NCoast.ORG
uunet!hal.cwru.edu!ncoast!allbery		    ncoast!allbery@hal.cwru.edu
"Why do trans-atlantic transfers take so long?"
"Electrons don't swim very fast."  -john@minster.york.ac.uk and whh@PacBell.COM

scs@hstbme.mit.edu (Steve Summit) (09/04/89)

In article <128@isgtec.UUCP> bmw@isgtec.UUCP (Bruce Walker) writes:
>You are supposed to start it like this (usually from .login):
>	$ checkmail&
>However, if you do this [under certain job-control csh's], the process
>disconnects from your tty and continues running (inherited by root).
>
>My (slightly klugey) solution is to add a line to my .logout (csh):
>	/bin/kill -9 `ps x | awk '$5=="checkmail" {print $1}'`&
>Anyone know a better way?

In article <92@harald.UUCP> jba@harald.ruc.dk (Jan B. Andersen)
correctly points out that:

>...TFM... says it all:
>     CSH(1B)
>	  Processes running in background (by &) are immune to signals
>	  generated from the keyboard, including hangups.
>
>Personally I find this behavior a bit odd. Why not use nohup(1)
>instead?

I consider this a bug in csh, though most doubtless consider it a
feature.  In the old days, it was considered the exception that a
background job would want to be left running after logout;
therefore, the HUP signal normally killed all processes, and
nohup had to be used explicitly when a background job was to be
left running.  (nohup also attempted to guarantee, in a
simpleminded but effective way, that the background job would not
scribble on the terminal, out of courtesy for the next person to
log in on it.  Now that "everybody" uses csh, nobody uses nohup
and this protection has disappeared, which was probably one
reason Berkeley had to invent vhangup, about which the inimitable
Chris Torek has said, "warning: don't look at [it] immediately
after eating food.")

Would one of the innumerable csh users and/or lovers out there
let this poor fellow know what the appropriate way of having
background demons killed on logout under csh is?  (There is an
appropriate, clean way, right?)

                                                Steve Summit

jbw@bucsf.bu.edu (Joe Wells) (09/04/89)

In article <14032@bloom-beacon.MIT.EDU> scs@hstbme.mit.edu (Steve Summit) writes:
   reason Berkeley had to invent vhangup, about which the inimitable
   Chris Torek has said, "warning: don't look at [it] immediately
   after eating food.")

Here's the correct quote:

  Whoa!  Don't look at vhangup(2) immediately after eating food.
	-- Rick Ace

--
Joe Wells <jbw@bucsf.bu.edu>
jbw%bucsf.bu.edu@bu-it.bu.edu
...!harvard!bu-cs!bucsf!jbw

argv%turnpike@Sun.COM (Dan Heller) (09/04/89)

In article <37484@bu-cs.BU.EDU> jbw@bucsf.bu.edu (Joe Wells) writes:
> Here's the correct quote:
> 
>   Whoa!  Don't look at vhangup(2) immediately after eating food.
> 	-- Rick Ace

Rick Ace?  The one who works at Pixar now?  He's my next door neighbor!
What a small world...  Isn't life funny... I think I'll walk over there
and have a talk with him about this :-)


dan <island!argv@sun.com>
-----
My postings reflect my opinion only -- not the opinion of any company.