Fork: Difference between revisions

Content added Content deleted
(→‎{{header|Perl}}: simpler examples)
Line 225: Line 225:
}</lang>
}</lang>


Obviously you could do a Fork in a lot less lines, but this code covers all the bases
Obviously you could do a Fork in a lot less lines, but this code covers all the bases.

Another example using [http://search.cpan.org/perldoc?Proc::Fork Proc::Fork] module:

<lang perl>use Proc::Fork;
run_fork {
child {
# child code ...
}
parent {
# parent code ...
}
};</lang>

Or:
<lang perl>use Proc::Fork;
# parent code ...
run_fork {
child {
# child code ...
}
};
# parent code continues ...</lang>

More complex example with retries and error handling:
<lang perl>use Proc::Fork;
run_fork {
child {
# child code ...
}
parent {
# parent code ...
}
retry {
# retry code ...
}
error {
# error handling ...
}
};</lang>


=={{header|PHP}}==
=={{header|PHP}}==