Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^6: Setting signal handlers

by dave_the_m (Monsignor)
on May 10, 2006 at 00:17 UTC ( #548353=note: print w/replies, xml ) Need Help??

in reply to Re^5: Setting signal handlers
in thread Setting signal handlers

Perl will only call a particular signal handler once per signal number - no matter how many times it recieves that signal type *before* handling it.

But there's a general flaw with your stress code; you have multiple processes all writing to stdout (which I presume is redirected to a file), and that's likely to lose or duplicate output, even with $|=1:

$ cat /tmp/p1 #!/usr/bin/perl $| = 1; for (1..10) { if (fork == 0) { print "$_\n" for 1..100; exit; } } $ perl588 /tmp/p1 > /tmp/x ; wc -l /tmp/x 900 /tmp/x $ perl588 /tmp/p1 > /tmp/x ; wc -l /tmp/x 983 /tmp/x $ perl588 /tmp/p1 > /tmp/x ; wc -l /tmp/x 1000 /tmp/x
Either open the file in append mode and only syswrite to it, or have each process write to a separate file.


Replies are listed 'Best First'.
Re^7: Setting signal handlers
by sgt (Deacon) on May 11, 2006 at 22:24 UTC
    well the output surprises the OS level a child will get a copy of the parent descriptor but __does share__ the file offset, so if they write at the same time, their output will be intermixed. but i really don't see how you can lose any \n on cygwin I cannot reproduce what you get tomorrow at work I will try on HP-UX... 100 runs with 1000 print in each process

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://548353]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2021-01-17 19:50 GMT
Find Nodes?
    Voting Booth?