Messages in this thread | | | Date | Wed, 5 May 1999 18:37:28 +0100 | From | Steve Dodd <> | Subject | Re: fork() Problem? |
| |
On Wed, May 05, 1999 at 09:52:23AM -0400, Richard B. Johnson wrote:
> > if (pid = fork()) > ^^^^________ logical test of an assignment? This will always > be true!
Not if the code is written in C, which it seems to be.
It'll be true if the result of fork() is true, or false otherwise. pid will be assigned the result of fork() in either case. As fork() returns 0 (false) in the child, and the PID of the child in the parent (true), what's the problem?[1]
S.
[1] Assuming fork() doesn't fail of course, which is reasonable in test code.
-- "If the bottom is falling out of your world, then have a drink here and the world will fall out of your bottom."
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |