Hello all,
Apparently Tuesday is just as bad. I have this subroutine:
sub StartErrorGuardian { my ($this, $pm) = @_; $this->Log("INFO","CWAPP: Starting error guardian\n"); $continue_flag = 1; if ($this->{bThreadStarted} == 0) { $this->{bThreadStarted} = 1; my $pid= fork(); if (not defined $pid) { $this->Log("ERROR","CWAPP: Could not start error guardian\ +n"); return 0; } if ($pid == 0) { $this->Guardian(); } else { return $pid; } } return 0; }
which creates (or should create) a child to handle with the Guardian subroutine.
sub Guardian { my ($this) = @_; my $i = 0; while (1) { {#find any message-box with class #32770 [usually infos and errors +] and press it's child OK button @err_window = FindWindowLike(undef, "", "#32770"); foreach (@err_window) { SetForegroundWindow($_); SetActiveWindow($_); PushChildButton( $err_window[$i], "OK", 0.25 ); PushChildButton( $err_window[$i], "Abort", 0.25 ); } sleep 1; } }
If I call the first subroutine from a normal script, everything goes just fine. If I make a fork() and call StartErrorGuardian from the child, nothing happens. And I meen literally nothing. The line my $pid= fork() just blocks the script. It does not pass it. I also tried using Parallel::ForkManager and threads but I get the same result.
So, what I would want to do would be to view some process information before the fork() line. Some kind of debugging, as running the script with -d just crashes at the first fork(). Any suggestions?
Thanks.

In reply to multithreaded debugging by Razvanica

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.