in reply to Re: Segmentation Fault
in thread Segmentation Fault

THX to virtualsue for this sugestion. I used alarm to simplified my code a lot. But problem is, that just simple using this:

eval { local $SIG{ALRM} = sub { die "alarm clock restart" }; alarm 10; qx/$string/; alarm 0; }; if ($@ and $@ !~ /alarm clock restart/) { die }

will genearate zombies as described in docs:

If the operation being timed out is system() or qx(), this technique is liable to generate zombies. If this matters to you, you'll need to do your own fork() and exec(), and kill the errant child process.

Because I need to capture output from command $string I can't use exec() command instead of backticks qx//. So this seems to be litle bit problematic.

Anybody know? THX

Li Tin O've Weedle
mad Tsort's philosopher

Replies are listed 'Best First'.
Re: Re: Re: Segmentation Fault
by virtualsue (Vicar) on Mar 07, 2002 at 17:35 UTC
    Consider writing a bourne shell script or a small C program that you run from backticks/qx/system in your main Perl program. Inside this subprogram, set the alarm and run your ping. I think that will put the signal handling where it belongs.