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.
This is the first background process:
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_nam
+e,$nn]);
Second can be anything, a simple xterm
system("xterm -e '$viewer $log' &")
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
-
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.