Subject: | Use slee() Instead of <> To Wait Until Killed |
Dear Elizabeth Mattijsen,
Hi. This is imacat from Taiwan. I found that your
Benchmark-Thread-Size-0.07 does not work when STDIN is not available,
I.E. redirected from somewhere else, like /dev/null or files. Further
investigation reveals that, when creating _test_ramthread in your
Size.pm, in order to wait until killed, it listens from STDIN. This
does not work when STDIN is attached to /dev/null or some other files.
To wait forever, you should use sleep() instead.
I attached the sample terminal log below. I made a simple patch to
Benchmark-Thread-Size-0.07, in the hope that it helps. Please tell me
if you have any question, or if I could be of any help. Thank you.
imacat@rinse tmp/Benchmark-Thread-Size-0.07 % make test </dev/null
t/Size01......1/8 Performing each test 2 times
(ref) 1 0make: *** wait: No child processes. Stop.
make: *** Waiting for unfinished jobs....
make: *** wait: No child processes. Stop.
imacat@rinse tmp/Benchmark-Thread-Size-0.07 % perl -Iblib/lib
-Iblib/arch t/Size01.t </dev/null
1..8
ok 1 - open script file
ok 2 - write script
ok 3 - close script
ok 4 - check whether script exists
ok 5 - run the test
Performing each test 2 times
(ref) 1 0
imacat@rinse tmp/Benchmark-Thread-Size-0.07 %
Subject: | Benchmark-Thread-Size-0.07-nostdin.diff |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
diff -u -r Benchmark-Thread-Size-0.07.orig/lib/Benchmark/Thread/Size.pm Benchmark-Thread-Size-0.07/lib/Benchmark/Thread/Size.pm
- --- Benchmark-Thread-Size-0.07.orig/lib/Benchmark/Thread/Size.pm 2003-12-29 06:54:19.000000000 +0800
+++ Benchmark-Thread-Size-0.07/lib/Benchmark/Thread/Size.pm 2008-04-05 03:08:57.000000000 +0800
@@ -271,7 +271,7 @@
threads->new( sub {print "started\\n"; sleep( 86400 )} );
}
print "done\\n"; # make sure the world knows we're done
- -<>; # make sure it waits until killed
+sleep 86400 while 1; # make sure it waits until killed
EOD
close( $script ) or die "Could not close $testfile: $!\n";
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkf2fPMACgkQi9gubzC5S1wS+gCeMFrzUGHjiHtDrkUYa1YUq6OG
/dkAoK+TE8sf3Vu8x7Jr3WLBWT7ogeXL
=WMDS
-----END PGP SIGNATURE-----