in reply to fork question

Maybe you take STDOUT away too early (buffering and race condition) ?

Does this work?
my $pid; if ($pid = fork) { local $| = 1; # patch1 print qq~<response type="4" status="1">~; print qq~ </response>\n~; } elsif (defined $pid) { sleep 1; # patch2 close STDOUT; #exit; my $myba = mybaapp->new(); my $linkbase = $myba->mob2myba($url); $myba->sendinfo($smsfrurl); exit; } else { die "Major error: $!"; } #end fork
Update: Ahhh, brainglitch. Forget this!
Some more things to check: Did you update any modules recently? Does mybaapp use I/O (STDOUT)? What do you mean by ignored? Does the child still print something to STDOUT? Does it work if you do not close STDOUT? Did you use warnings;? Any warnings seen (e.g. print() on closed filehandle STDOUT at xxx line yyy.)? Any signals caught (SIGPIPE, SIGCHLD, etc.)? What does the main program (parent) do? Does it wait?

Replies are listed 'Best First'.
Re^2: fork question
by jonnyfolk (Vicar) on Aug 08, 2011 at 15:15 UTC

    Hi, thanks for your reply. Unfortunately that doesn't seem to be the problem - even increasing sleep to 5 just keeps hanging

      You might have better luck trying to close or permanently redirect all filehandles. It may even be that you need to close ALL filehandles which you might have open. Maybe in the intervening time since the script was working, and not, you added some code elsewhere which opened some filehandles? See how to close all files
      close(STDOUT);close(STDIN);close(STDERR);
      or even
      open STDIN, "</dev/null"; open STDOUT, ">/dev/null"; open( STDERR, ">>/path/to/logfile");

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh