Nohup doesn't work as I need with ksh on Solaris 2.6

Nohup doesn't work as I need with ksh on Solaris 2.6

Post by Pierre-Philippe Ravi » Wed, 05 Sep 2001 03:11:44



Hi,

I can't get nohup to work as I want. ksh is my login shell.
Basically, I have a shell script, having this first line :
#!/bin/ksh

This script does a few things, then ultimately starts a binary program
which I want to run permanently. Trying to achieve this goal, I did
the following sort of things in the script :
trap "" HUP
nohup mybinary

I also type the trap instruction in the interactive shell, and launch
the shell script with a nohup command.
Unfortunately, my job is killed if I exit the shell (after the usual
warning about running jobs).

I am puzzled. Could you help me please ?

 
 
 

Nohup doesn't work as I need with ksh on Solaris 2.6

Post by Pierre-Philippe Ravi » Wed, 05 Sep 2001 17:31:52


I found a solution to this problem, it might be interesting for
someone else to know how to solve it, so here it is :

instead of trying to start my process with nohup, I found a very
different approach :

I start the process, from my script, like this :
exec myprocess &

The process started by exec and set in bakground byu the ampersand
sign is completely detached from the shell. Its parents becomes the
process 1, as if it was started from cron.
When I exit the shell, the process carries on happily. No need to use
the trap or the nohup functions.

Quote:> Hi,

> I can't get nohup to work as I want. ksh is my login shell.
> Basically, I have a shell script, having this first line :
> #!/bin/ksh

> This script does a few things, then ultimately starts a binary program
> which I want to run permanently. Trying to achieve this goal, I did
> the following sort of things in the script :
> trap "" HUP
> nohup mybinary

> I also type the trap instruction in the interactive shell, and launch
> the shell script with a nohup command.
> Unfortunately, my job is killed if I exit the shell (after the usual
> warning about running jobs).

> I am puzzled. Could you help me please ?