in reply to detached process in windows
The simplest way is to use the barely documented system-with-a-first-argument-of-1 asynchronous system. It's not portable outside of Win32, but it is roughy analogous to appending '&' to the end of a unix command.
#! perl -slw use strict; if( @ARGV ) { print 'I am the child. I got args: ', join', ', @ARGV; sleep 10; print 'Child ended'; } else { print 'I am the parent'; for ( 1 .. 3 ) { print "Starting child $_"; system 1, $0, 'An arg', $_; } print 'Parent continuing'; sleep 10; print 'parent exiting'; } __END__ c:\test>junk I am the parent Starting child 1 Starting child 2 Starting child 3 Parent continuing I am the child. I got args: An arg, 2 I am the child. I got args: An arg, 3 I am the child. I got args: An arg, 1 parent exiting c:\test>Child ended Child ended Child ended
|
---|