mwhamilton
Technical User
Hi,
I am spawning a bunch of child processes with fork, and I need some help with performing some actions inside the child processes. After I fork, I need to switch machines, switch directories, and then call a script. The problem is that when I change hosts, it changes it in the xterm that I have called the original forking script. I basically need the freedom to have my child process change hosts, change directories, and run a script without the original terminal ever knowing the difference. But, I do need the output of the script to print to the STDOUT. Any help would be greatly appreciated!
for ( $i=0; $i<=$#commands; $i++ ) #for number of commands
{
$cmd = $commands[$i];
# HIT MAXIMUM? WAIT FOR A CHILD TO FINISH
if ( $count >= $maxcount )
{
# WAIT FOR A CHILD
if ( ($pid = wait()) != -1 )
{
$count--;
&Finish($i, $count, $pid);
}
}
check:
$host = &chk_avail();
if(!$host){
print"All machines currently busy. Waiting for available machine...\n";
sleep 5;
goto check;
}
# START A NEW CHILD
if ( ( $pid = fork()) == 0 )
{
CHILD:
$machines_in_use{$host} = $pid;
#Need Help with these system commands#
rsh $hew_host;
cd ~/project_dir;
script.pl
exit(1);
}
else
{
# PARENT
$children{$pid} = $cmd;
&Started($i, $count, $pid);
$count++;
}
}
I am spawning a bunch of child processes with fork, and I need some help with performing some actions inside the child processes. After I fork, I need to switch machines, switch directories, and then call a script. The problem is that when I change hosts, it changes it in the xterm that I have called the original forking script. I basically need the freedom to have my child process change hosts, change directories, and run a script without the original terminal ever knowing the difference. But, I do need the output of the script to print to the STDOUT. Any help would be greatly appreciated!
for ( $i=0; $i<=$#commands; $i++ ) #for number of commands
{
$cmd = $commands[$i];
# HIT MAXIMUM? WAIT FOR A CHILD TO FINISH
if ( $count >= $maxcount )
{
# WAIT FOR A CHILD
if ( ($pid = wait()) != -1 )
{
$count--;
&Finish($i, $count, $pid);
}
}
check:
$host = &chk_avail();
if(!$host){
print"All machines currently busy. Waiting for available machine...\n";
sleep 5;
goto check;
}
# START A NEW CHILD
if ( ( $pid = fork()) == 0 )
{
CHILD:
$machines_in_use{$host} = $pid;
#Need Help with these system commands#
rsh $hew_host;
cd ~/project_dir;
script.pl
exit(1);
}
else
{
# PARENT
$children{$pid} = $cmd;
&Started($i, $count, $pid);
$count++;
}
}