[San-diego-pm] another bug in perl: rand/OSX?
C. Abney
cabney at ucsd.edu
Wed Jun 2 16:15:22 CDT 2004
Maybe my keywords suck and this is a known issue?
Running this script on a Mac OSX gives very unexpected results:
=8<============
#! /usr/bin/perl -w
# spawn some kids and check up on them periodically without actually
# waiting to harvest them...
my ( $pid, @jobs, $n );
$|++;
for (0..2)
{
$pid = fork();
last if $pid == 0;
push @jobs, $pid;
}
if ( @jobs && $pid != 0 ) {
# parental responsibilities
$SIG{CHLD} = 'IGNORE';
$n = kill 0, @jobs;
print "jobs: @jobs\n";
while ( 0 < $n ) {
print "we have $n children, Houston\n";
sleep 2;
$n = kill 0, @jobs;
}
exit 0;
} else {
my $slp = int rand 20;
print "child to sleep $slp second(s)\n";
sleep int rand 20;
print "\nmama, I'm so gone!!!\n";
exit 0;
=8<============
It's rand()s behavior on the Mac I'm concerned about.
from uname:
Darwin odonata.ucsd.edu 7.3.0 Darwin Kernel Version 7.3.0: Fri Mar 5
14:22:55 PST 2004; root:xnu/xnu-517.3.15.obj~4/RELEASE_PPC Power
Macintosh powerpc
perl --version:
This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level
(with 1 registered patch, see perl -V for more detail)
To be explicit: each child gets the same value returned from rand.
Yours,
Charles
--
Charles Abney
Polymorphism Research Laboratory, 0603
UCSD School of Medicine
9500 Gilman Dr.
La Jolla, CA 92093-0603
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.pm.org/pipermail/san-diego-pm/attachments/20040602/fe088058/attachment.bin
More information about the San-Diego-pm
mailing list