1833587 Members
3905 Online
110061 Solutions
New Discussion

Process getting SIGHUP

 
SOLVED
Go to solution
Deepak Extross
Honored Contributor

Process getting SIGHUP

Hi,

I have this script, say start_procs.sh, that starts up some executables in the background with
' su - -c "nohup &" '
When I invoke this script from the command-prompt, all is well - the processes start, and continue to run in the background till they are explicitly 'kill'ed.

Funny thing is, when I invoke start_procs.sh from the startup file /etc/rc, the processes get a SIGHUP as soon as start_procs.sh exits.

Where am I goofing up?
7 REPLIES 7
Roger Baptiste
Honored Contributor

Re: Process getting SIGHUP

Deepak,

If you want to start the scripts as a part
of bootup process, it should be a run-level
startup script under /sbin/init.d directory
with a link to /sbin/rc3.d/Snnn<script> .

There should be a template file in the
/sbin/init.d directory. Make a copy of
it and modify the contents under "start"
case option to include the command
"su xx -c "...." .

/etc/rc is not the correct location
to start off user-defined scripts, since
the system is not completed its booting
process.

-R
Take it easy.
Deepak Extross
Honored Contributor

Re: Process getting SIGHUP

R,
Tried that too. But the problem remains - the processes start up, but get signal 1 when my script exits.

-deepak.
Eugen Cocalea
Respected Contributor

Re: Process getting SIGHUP

Hi,
Try with:

su - -c "nohup 1>/dev/null &"

E.
To Live Is To Learn
harry d brown jr
Honored Contributor
Solution

Re: Process getting SIGHUP

during boot, rc will kill all child pocesses on exit.

Instead of:

su - -c "nohup &"

Try "nohup'ing" your "su"

nohup su - -c " " &


live free or die

harry
Live Free or Die
Eugen Cocalea
Respected Contributor

Re: Process getting SIGHUP

Hi again,

Oops, I should have seen that :) given the fact that I tried several times to get the SIGHUP and didn't succeed (worked as you wanted).

E.
To Live Is To Learn
Frank Slootweg
Honored Contributor

Re: Process getting SIGHUP

nohup(1) takes some time to startup and do its work. Because of the "&", the nohup command is started in the background and the calling script continues. If the calling script terminates quickly, it will terminate before nohup has had the chance doing its work and hence the nohup-ed command will still get a SIGHUP signal.

A hack workaround for this is to put a small (few second) sleep command after the "... nohup ...&" to allow nohup to do its work.

A better method is to check (with ps(1)) in a loop if the nohup-ed command has actually started. If not, loop. If so, exit from the loop.
Deepak Extross
Honored Contributor

Re: Process getting SIGHUP

Thanks to all who chipped in.
Harry gets full marks for cracking this one!