[comp.unix.questions] /etc/rc.2 and background processes

gda@creare.UUCP (Gray Abbott) (12/11/88)

I have a Microport SYS V/AT and have a question about about /etc/rc.d .
I want to have the system check for the need to run a tape backup at
boot time and run the backup if needed.  I wrote scripts which
properly decides whether to do the backup, including asking for console
input to confirm the operation; then that script runs a second script,
in the background, which actually does the backup.  All of that worked
fine, but when I placed the first script in /etc/rc.d, the second
script fails to finish.

I think this happens because init is sending a SIGKILL to the
background process when /etc/rc2 exits, or something like that.  The
inittab has /etc/rc2 running at level 2, but also with the "action"
specified as "wait".  If I have the first script run the second in the
foreground, everything works, but I have to wait for the whole backup
to complete before I can login.

Anyway, I'd like to know what's going on, and also how to make it do
what I want.  Why does the background process die?  How can I prevent
this?


					..dartvax!creare!gda

Friedrich@cup.portal.com (Frank G Kienast) (12/12/88)

>I think this happens because init is sending a SIGKILL to the
>background process when /etc/rc2 exits, or something like that.  The
>inittab has /etc/rc2 running at level 2, but also with the "action"
>specified as "wait".  If I have the first script run the second in the
>foreground, everything works, but I have to wait for the whole backup
>to complete before I can login.

>Anyway, I'd like to know what's going on, and also how to make it do
>what I want.  Why does the background process die?  How can I prevent
>this?

I had a similar problem on a 3B15.  All I had to to to cure it was to
start the second process nohup.  You might also want to trap both SIGHUP
and SIGKILL.  Look at other scripts in /etc/rc2 for examples how to do
this.

Friedrich@cup.portal.com
s
?

rwhite@nusdhub.UUCP (Robert C. White Jr.) (12/13/88)

in article <890@creare.UUCP>, gda@creare.UUCP (Gray Abbott) says:
> Anyway, I'd like to know what's going on, and also how to make it do
> what I want.  Why does the background process die?  How can I prevent
> this?

Everything from /etc/rc().d is run under a single shell.  when you
release execution back to the master shell it is getting "death of a
parent"ed to death.  You will either have to protect the shell against
signals, or run it some different way.

How 'bout adding the script to /etc/inittab at the bottom with the code
"once".  It dosn't really have to be at the end, but this way the gettys
are running before the process starts.

Rob.

hudson@vsedev.VSE.COM (C Hudson Hendren III) (12/14/88)

In article <12504@cup.portal.com> Friedrich@cup.portal.com (Frank G Kienast) writes:
>[...]  You might also want to trap both SIGHUP
>and SIGKILL. [...]

You cannot set a trap for SIGKILL.  No, not even root can set a trap for
SIGKILL.
-- 
==> ..!uunet!vsedev!hudson  [hudson@vsedev.vse.com]  (C Hudson Hendren III) <==
==> These are my opinions and are not necessarily those of VSE Corporation. <==
==>	   MS-DOS was created to keep idiots away from UNIX computers	    <==