• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Process exit notifcation in a kext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Process exit notifcation in a kext


  • Subject: Re: Process exit notifcation in a kext
  • From: Dave Keck <email@hidden>
  • Date: Wed, 16 Jun 2010 03:27:46 -1000

> The relevant snippet is:
>
> "Every process has a process identification number (PID) that is
> assigned according to order it was run. The first process that runs
> has a PID of 1. The second has a PID of 2 and so on. If a process dies
> or is killed, that PID is not reused. If the computer is restarted,
> the process count begins at 1 again."

What I meant to say is that I read that document, but it's simply not
true that PIDs aren't reused. You can verify this easily (the upper
bound appears to be around 100,000):

=========================

#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>

int main()
{
    for (;;)
    {
        if (!fork())
            printf("%d\n", getpid()),
            _exit(0);
        else
        {
            int s, wr;
            do errno = 0, wr = wait(&s);
            while (wr == -1 && errno == EINTR);
        }
    }
    return 0;
}

=========================

I assume what the document means is that PIDs aren't immediately
reused when a process exits, but will be reused when the upper bound
is hit. That's an implementation detail though, and I know Terry's
mentioned before that PID randomization may happen eventually. So it's
best to consider the potential race conditions, which it sounds like
you've already been contemplating.

> I am using process exit notifications to clean up the list of PIDs for
> which traffic is filtered.

The other more knowledgeable people on this list will probably need to
help here.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Process exit notifcation in a kext
      • From: Wade Tregaskis <email@hidden>
References: 
 >Process exit notifcation in a kext (From: Bogdan Harjoc <email@hidden>)
 >Re: Process exit notifcation in a kext (From: Bogdan Harjoc <email@hidden>)

  • Prev by Date: Re: Process exit notifcation in a kext
  • Next by Date: Re: Process exit notifcation in a kext
  • Previous by thread: Re: Process exit notifcation in a kext
  • Next by thread: Re: Process exit notifcation in a kext
  • Index(es):
    • Date
    • Thread