What you want is to explicitly fork() then exec(). That's the tried-and-true traditional way to launch another process on Unixy systems, and fork() returns the child's PID in the parent (and 0 in the child, or undef if the fork() failed).
This code is simple, but it shows the concept.
if ( my $pid = fork() ) {
my $pid_of_child_that_finished = wait();
my $status_code_of_child = $?; # or $CHILD_ERROR_NATIVE
} elsif ( defined $pid ) {
exec( '/bin/ls' );
} else {
warn "Something broke: can't fork()!\n";
}
# continue processing in the parent after child is done
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|