On 10/19/06, Helliwell, Kim <[EMAIL PROTECTED]> wrote:
I would like the parent to continue independently of the child.
It sounds as if you want to use the double-fork trick. The first fork produces a child process; this child forks a grandchild process, then quits. The grandchild process does the work, and the original parent process doesn't have to wait once the child quits. On most Unix systems, the grandchild process will be "adopted" by another process (conventionally init, process id 1) once its true parent process is finished. Since you want to have a pipe from the parent to the grandchild, you should set that up before the double fork. I generally use Perl's pipe function to make a pair of filehandles; after forking, the parent closes the read handle and the grandchild closes the write handle (or vice versa, if you want data flowing the other way). The grandchild should re-open STDIN to the read handle before the exec, if I'm correct about what you want; that might look something like this: open STDIN, "<&READPIPE" or die "Can't re-open STDIN to READPIPE: $!"; After that, the process started by the exec should inherit that STDIN stream, reading whatever the parent sends down the write end of the pipe. A special caution is that if the reading process doesn't consume the input quickly enough, the parent process will block when its output buffer becomes full. If that becomes a problem for your application, ask again; there are ways to work around that. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>