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


In reply to Second background process is pausing the gui by Ohad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.