Re: Launching And Detaching
- From: axel@xxxxxxxxxxxxxxxxxxxxxx
- Date: Thu, 08 Sep 2005 11:27:34 GMT
Hal Vaughan <hal@xxxxxxxxxxxxxxxxxxxx> wrote:
> I'm using one simple program to launch some daemons. When I launch a
> program, I use backticks. (This is all on Linux, in bash, btw.) I've
> added "2>&1 >/dev/null &" to the command line, so it's like this:
>
> `/path/to/program 2>&1 >/dev/null &`;
>
> I've noticed that if I include the '&' so the program detaches from the
> shell, if I kill the launching program, the child process survives. I've
> also tried this by forking first:
>
> if (!fork()) {
> `/path/to/program 2>&1 >/dev/null &`;
> exit;
> }
>
> I had the hope that if I forked and launched like this, once all the
> programs were launched, the launching program would exit. It doesn't. Is
> there a way I can launch a program, then have the first program exit, so
> it's no longer using that bash instance (without killing it)?
You should not been using backticks for this purpose - they
are designed to collect data from the external program
and will wait for that program.
Have a look at: perldoc -f exec
Axel
.
- Follow-Ups:
- Re: Launching And Detaching
- From: Hal Vaughan
- Re: Launching And Detaching
- References:
- Launching And Detaching
- From: Hal Vaughan
- Launching And Detaching
- Prev by Date: <> and filehandles in hashes
- Next by Date: Re: <> and filehandles in hashes
- Previous by thread: Re: Launching And Detaching
- Next by thread: Re: Launching And Detaching
- Index(es):