lkml.org 
[lkml]   [1999]   [May]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.281 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site