Re: Process exit notifcation in a kext
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=amnjzZXiWW4/ydkqjIRFY4wf96RAznEDRThSlvMhji4=; b=djCfJmYYwj0HjDBaWZCAucRDLPYBSOWQUPRL3U7Sp5P7Iu7NEdFZb8McaaZDFALWQK JUjLCe11vohf7XtF1v97mxmZScKXLPGpm49AVeQ0AxZXyZ3O4Gh+4tjVmJTp0qf/FPta qavbboWHEf7NTOsiunewXsEnAifpQI4Bm3Yyc= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=q9rSQ5AoesW4Rwfs5xuELqM7MSe0BbAt+SW2Jatza3AMH8FTsVNEMg0+3xPeJJa06p rjznxTfpNEK1NRcsErNfG9VevKVIIb8UhRqvsPVdOy1TsPMDAblEFgrfrJe8OGUU/Na3 NUsPMjsmwMcTqSY/yb7TaFucK4AgUzb1eMEXw=
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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Dave Keck