#!/usr/bin/perl -wT use strict; my $pid1=fork(); unless($pid1) { # First child my $stdout_file = 'child1_stdout.log'; my $stderr_file = 'child1_stderr.log'; local(*STDERR); local(*STDOUT); open(STDOUT1, '>'.$stdout_file) or die $stdout_file . ': ' . $!; open(STDERR1, '>'.$stderr_file) or die $stderr_file . ': ' . $!; open(STDOUT, ">&STDOUT1") or die "Couldn't redir stdout: $!"; open(STDERR, ">&STDERR1") or die "Couldn't redir stderr: $!"; system('cmd1'); close(STDOUT1); close(STDERR1); exit(); } my $pid2=fork(); unless($pid2) { # Same thing but call cmd2 instead of cmd1 exit(); } # Don't forget to wait for each child wait(); wait();