Skip to content

Commit

Permalink
- Added srand() after each fork to re-seed the random numbers.
Browse files Browse the repository at this point in the history
Example:
	10.times {
 	   say ({rand(20)}.fork.get);  # prints random number
           say rand(20);	       # print a different random number
	}
  • Loading branch information
trizen committed Jul 18, 2015
1 parent 17cc1c2 commit 8fdb831
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/Sidef/Types/Block/Code.pm
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ package Sidef::Types::Block::Code {

my $pid = fork() // die "[FATAL ERROR]: cannot fork";
if ($pid == 0) {
srand();
Storable::store($self->run, $filename);
exit 0;
}
Expand Down

0 comments on commit 8fdb831

Please sign in to comment.