home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!rde!ksmith!keith
- From: keith@ksmith.uucp (Keith Smith)
- Subject: Re: Background processes not dying on parent exit
- Organization: Keith's Computer, Hope Mills, NC
- Date: Thu, 10 Sep 92 15:11:34 GMT
- Message-ID: <1992Sep10.151134.8267@ksmith.uucp>
- References: <1992Aug31.071515.24296@klaava.Helsinki.FI> <20189@plains.NoDak.edu> <1992Sep6.225138.11383@klaava.Helsinki.FI>
- Lines: 79
-
- In article <1992Sep6.225138.11383@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
- >I said that children shouldn't be killed when their parent dies.
-
- That depends, see below...
-
- >
- >person@plains.NoDak.edu (Brett G Person ) asks in reply:
- >>Why is it done this way? This is kinda sloppy. I know that
- >>somethimes unix will forget to kill one of my processes, but it
- >>doesn't seem to happen very often. Why would linux be designed this
- >>way?
- >
- >As far as I am aware, no Unix kills children when the parent dies. I
- >see no reason why processes should be killed for arbitrary reasons like
- >some other process dying.
-
- That depends on the shell you are using and NATURE of the process. It
- should be up to the forked process whether or not it dies, not the OS.
- The DEFAULT action needs to be death!
-
- What SHOULD happen in my experience is the CHILD process should receive
- a SIGHUP when the parent dies. The DEFAULT action for SIGHUP should be
- death. This is VERY important from a minimal security standpoint.
-
- The child process can dissassociate itself from it's parent with the
- setpgrp() System call. Alternately it can also choose to trap the
- SIGHUP signal and continue on accordingly.
-
- In SCO ISC and SVR4 a standard forked shell job dies when you log out
- unless it is 'nohup'ed:
-
- someprog < /dev/null >$HOME/someprog.out 2>&1 &
-
- someprog:
- -------
- : # For SCO
- #!/bin/sh for other stuff
-
- while true
- do
- date
- sleep 600 # 10 Minutes
- done
- -------
-
- >
- >Also, do you think that the following should work:
- >
- > #!/bin/sh
- > (sleep 10; echo 10) &
- > (sleep 5; echo 5) &
- >
- >A similar thing happens with some program, e.g. some mailers leave a
- >background child process behind to do the real work, so that the user
- >doesn't need to wait as long for a prompt. Should this be impossible?
-
- No, The script would need to 'nohup' the background children, *OR* the
- script itself could be nohup'ed, *OR* the program if written in 'C' can
- setpgrp or trap SIGHUP. Most mailer type jobs will fork and spool the
- work, otherwise the set the signal or process group to protect
- themselves.
-
- >
- >Note that doing nohup isn't the answer: it could still be a good idea
- >for some leftover child processes of this kind to be killed on hangup.
- >
-
- Now, also note that certian shells (tcsh for 1 and I THINK ksh will
- warn you at logout, but I'm not sure on this one) Automagically nohup
- all the shells doing a signal(SIGHUP,SIG_IGN) before forking it off.
-
- >--
- >Lars.Wirzenius@helsinki.fi
-
-
- --
- Keith Smith uunet!ksmith!keith 5719 Archer Rd.
- Digital Designs BBS 1-919-423-4216 Hope Mills, NC 28348-2201
- Somewhere in the Styx of North Carolina ...
-