public inbox for linux-8086@vger.kernel.org
 help / color / mirror / Atom feed
From: Harry Kalogirou <harkal@gmx.net>
To: jb1@btstream.com
Cc: Linux-8086 <linux-8086@vger.kernel.org>
Subject: Re: fork bug [WAS: Re: "mount" bug]
Date: 27 Oct 2002 21:49:46 +0200	[thread overview]
Message-ID: <1035747909.8585.43.camel@cool> (raw)
In-Reply-To: <Pine.LNX.4.33.0210270416350.5872-100000@olympus.btstream.com>

[-- Attachment #1: Type: text/plain, Size: 1276 bytes --]

> On 26 Oct 2002, Harry Kalogirou wrote:
> 
> > "Cannot fork" is emmited by the shell, when the fork() system call
> > fails. The system call will fail :
> > 
> > 1) If there are no more process slots available.
> > 2) There is not enough free memory.
> > 
> > What exacly happend there, I realy can't tell. The only thing I can tell
> > is that something "very" bad happed there. I personaly havedn't seen
> > ELKS behave like that before. 
> 
> There appears to be a bug in the "get_pid()" function from fork.c. The 
> code fragment:
>     if (++last_pid == 32768)
>         last_pid = 1;
> must eventually fail because last_pid is declared as type pid_t, which is 
> typedef'ed as __s16, which is in turn typedef'ed as signed short int. 
> Since signed 16-bit numbers roll over from 32767 to negative numbers, they 
> can never equal 32768. A possible fix might be:
>     if ( (++last_pid && 0x7fff) == 0 )
>         last_pid = 1;
> or, perhaps smaller and faster:
>     if !( (last_pid++) &= 0x7fff )
>         last_pid++;
> The latter may have superfluous parentheses because I'm not sure of the 
> precedence, and whether "variable++" is smaller and faster than 
> "++variable" is probably compiler-dependent.
> 

Commited...

Harry



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 232 bytes --]

      reply	other threads:[~2002-10-27 19:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-25  9:28 "mount" bug jb1
2002-10-25 13:30 ` Harry Kalogirou
2002-10-26  8:55   ` jb1
2002-10-26 14:49     ` Harry Kalogirou
2002-10-27 12:57       ` fork bug [WAS: Re: "mount" bug] jb1
2002-10-27 19:49         ` Harry Kalogirou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1035747909.8585.43.camel@cool \
    --to=harkal@gmx.net \
    --cc=jb1@btstream.com \
    --cc=linux-8086@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox