On 23 Sep 2002 10:33:04 -0400 Peter Chen wrote:
+------------------
| Rocco,
|
| One of my coworkers who uses my POE-based framework discovered an
| interesting semantic difference between using POE::Wheel::Run running a
| Perl function vs. the typical fork-exec.
|
| Observe the results of these two one-liners:
|
| perl -e 'rand; if (fork) { print rand } else { print rand }'
|
| perl -e 'rand; if (fork) { print rand } else { exec("perl -e \"print
| rand\"") }'
|
| W/o an exec, the first and second rand() will always produce the same
| result.
|
| Would it make sense for POE::Wheel::Run to call srand before the perl
| function is executed in the child process?
|
| Pete
+------------------
The behavior is understandable. Both parent and child sequences
are seeded from the same initial value. This behavior is an important
feature of psuedo random number generators. I can imagine scenarios
where this behavior might be desireable. Maybe a better approach
for your coworker would be to use /dev/random or prngd.
--