site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com User-agent: Thunderbird 2.0.0.24 (Macintosh/20100228) Jonas Maebe wrote: On 16 Sep 2011, at 22:12, Ingemar Ragnemalm wrote: You also have to reap the child processes. So something like this: void RunTest(int i) { int pty, childpid, res; /Ingemar _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Thanks, but it doesn't explain why it would fail after a pretty exact number of runs. And it still does, with the correction. switch((childpid=forkpty(&pty, NULL, NULL, NULL))) { case -1: // Error printf("pty error after %d\n", i); exit(1); case 0: // Child _exit(0); default: // Parent do { res = close(pty); } while ((res == -1) && (errno == EINTR)); do { res = waitpid(childpid,NULL,0); } while ((res == -1) && (errno == EINTR)); } } You are right, that did it for this example! Only one detail: AFAIK the EINTR checks are superfluous in the default setting, since the default behavior is to restart the interrupted call. That will save some lines of code. That is, granted that this is default on OSX and not only on some other Unix. So if I miss a close, it locks up after about 30 runs since I run out of ptys, and if I miss a waitpid I will run out of child processes since I get too many zombies. I suppose that the limit is 256. This email sent to site_archiver@lists.apple.com
participants (1)
-
Ingemar Ragnemalm