perlquestion
Ohad
<p> Hi, I'm using perl/Tk.
I've created a background process to run a cmd and I want the main process to continue working.
This is fine and works, until I invoke an additional background process.
Than the GUI is stuck until the first process is done. </p>
<p> This is the first background process:</p>
<code> open (my $st_in, "<&STDIN");
open (my $out, '>&', STDOUT);
open (my $err, '>&', STDERR);
open (STDOUT, "> /dev/null");
open (STDERR, "> /dev/null");
open (STDIN, "< /dev/null");
my $status = open ($reg_out,"$cmd 2>&1 |") or die "can't fork: $!";
if ($status) #Parent
{
open (STDOUT, '>&', $out);
open (STDERR, '>&', $err);
open (STDIN, '<', $st_in);
}
else
{
exit;
}
$Reg_r{$regl_name}{$nn}{'OutP'} =$reg_out;
$Reg_r{$regl_name}{$nn}{'PID'} = $status;
$Reg_r{$regl_name}{$nn}{'JobId'} = 0;
$Reg_r{$regl_name}{$nn}{'IsRun'} = 1;
$Reg_r{$regl_name}{$nn}{'WasRuning'} = 0;
$book->raise("Sheet 1") if ($re_run_csv);
$Sbook->raise("$regl_name $nn");
$mw->fileevent($reg_out, 'readable', [\&fill_text_widget,$regl_name,$nn]);</code>
<p> Second can be anything, a simple xterm</p>
<code> system("xterm -e '$viewer $log' &") </code>
<p> Any idea how to solve it? So the main process will not be stuck?
As you see in the code, I tried many options, exec/system/`,I tried closing STDs..
Could really use some advice here</p>