Is that right?D is in position 3, with pid 26031 That's what I said... D is in position 3, with pid 26031 C is in position 2, with pid 26030 That's what I said... C is in position 2, with pid 26030 B is in position 1, with pid 26029 That's what I said... B is in position 1, with pid 26029 A is in position 0, with pid 26028 That's what I said... A is in position 0, with pid 26028 E is in position 4, with pid 26032 That's what I said... E is in position 4, with pid 26032
It doesn't work that way because the children are running in parallel, so there is no guarantee that a child will get to print its two lines w/o another child printing anything in between. To better illustrate this, try putting a sleep 3; between the two print statements.... I think that might help you grok whats happening.
Two side notes: 1.) You really should use strict and 2.) You don't have to hit enter to get a prompt. Your shell is coming back almost immediately... *before* the children are done printing. Therefore, your prompt is getting mixed in with the output of your script. Try entering a command after your program runs to see what I mean.
-Blake
In reply to Re: deterministic fork
by blakem
in thread deterministic fork
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |