bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AIX and Interix also do early PID recycling.


From: Steven W. Orr
Subject: Re: AIX and Interix also do early PID recycling.
Date: Wed, 25 Jul 2012 09:44:07 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Thunderbird/3.1.20

On 7/25/2012 9:20 AM, Michael Haubenwallner wrote:

On 07/25/2012 09:59 AM, Michael Haubenwallner wrote:
On 07/25/2012 03:05 AM, Chet Ramey wrote:
Bash holds on to the status of all terminated processes, not just
background ones, and only checks for the presence of a newly-forked PID
in that list if the list size exceeds CHILD_MAX.

The AIX 6.1 I've debugged on has:
   #define CHILD_MAX 128

I'm going to run this build job with 'truss -t kfork' again, to eventually find
some too small count of different PIDs before PID-recycling by the kernel...

Tracing shows:

The minimum fork count (including grand-childs to any depth) before PID 
recycling starts
looks like 255 (once), but usually 256 and more.

However, one process does see a PID recycled after *at least* 128 forks,
that is exactly the value of CHILD_MAX.

First thought is of some off-by-one bug, but reducing js.c_childmax in jobs.c 
(2 times)
by one doesn't help.

Investigating further... any hints what to look out for?

/haubi/


One thing that just springs to mind: Under AIX, I believe (but don't take this as gospel) that PIDs are not strictly ascending. The low byte may increment, but it might be another byte in the pid_t that gets the increment, and the byte that increments may alternate. I don't know if anyone else does this, but I seem to remember that AIX does (or did).

You might write a little C program that does a loop of 1000 fork and wait calls. Just print out the pids that you create. Something like this...

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>

main()
{
    pid_t pid;
    int status;
    int ii;

    for (ii = 0; ii < 1000; ii++)
    {
        if ((pid = fork()) != 0)
        {
            printf("New child:%d\n", pid);
            waitpid(pid, &status, 0);
        }
        else
            exit(0);
    }
}

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]