in reply to hanging process

Redirecting output isn't goint to help if the program wants input. You probably want to make sure you've redirected anything in stdin/stdout/stderr that you don't want the child to inherit from the parent. Of course, nohup will do that for you for stdout/stderr. Try one of the following depending on how much input the program needs...
# You need EOF on input... system("nohup program </dev/null >/dev/null 2>&1 &"); # You need 1 line of empty input... system("/bin/echo | nohup program >/dev/null 2>&1 &"); # You need infinite lines of empty input system("yes '' | nohup program >/dev/null 2>&1 &");
... all of which are kludgey and assume you don't care about error handling here (e.g. no nohup output; does program really start up ok?).

bluto

Replies are listed 'Best First'.
Re: Re: hanging process
by pappajaz (Novice) on Oct 28, 2003 at 15:38 UTC
    The program starts up okay. The program itself doesn't require any input. Its a "daemon" process but locks on occasion so I have written a kill script and this is the start script. The problem I have been having is that the internal shell from exec or system does not seem to exit after the program is finished executing. I did try typing in 'ls' and it executed as if the shell was still open. I have seen this appear often when backgrounding processes. This is where I got the <newline> comment.
    The web interface looks for output from nohup on stdout. Beyond the fact..the program works but hangs on the web interace. I have another program which calls 'ps -ef| grep <input>' and it shows the program running no problem.

    Thank you,

    Adam