lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20090409123644.GA10495@mail.local.tull.net>
Date:	Thu, 9 Apr 2009 22:36:44 +1000
From:	Nick Andrew <nick@...k-andrew.net>
To:	Bernd Petrovitsch <bernd@...mix.at>
Cc:	Sino <szj087@...il.com>, linux-kernel@...r.kernel.org
Subject: Re: the different effect of system call fork()

On Wed, Apr 08, 2009 at 03:08:48PM +0200, Bernd Petrovitsch wrote:
> >    if (pid_t pid = fork() < 0)
> 
> I don't think that this line does what you want it to do.
> Hint: Using a "pid_t" for the boolean result for a comparison seems
> strange at best.

The "problem" is due to a misunderstanding of C/C++ operator precedence.

"(pid = fork() < 0)" binds like "pid = (fork() < 0)" and so pid always
has a value of zero and so both parent and child process run the "first
level child process" code ... soon there are 4 processes all confused
about who they are.

Nick.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ