site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Importance: Normal User-agent: SquirrelMail/1.4.16 Is there anyone here who knows forking and ptys well? I have been trying to fix my failing ptys for quite some time (like, now and then for a few years), and now I am trying again, and have narrowed it down to a small demo: --- #include <stdio.h> #include <util.h> #include <stdlib.h> #include <unistd.h> void RunTest(int i) { int pty; switch(forkpty(&pty, NULL, NULL, NULL)) { case -1: // Error printf("pty error after %d\n", i); exit(1); case 0: // Child _exit(0); default: // Parent close(pty); } } int main(int argc, char *const argv[]) { int i; for (i = 0; i < 1000; i++) RunTest(i); printf("Successfully ran %i times\n", i); exit(0); } // Ultra-minimal pty demo showing the problem I have with failing pty code. // The program just creates and closes ptys over and over. // This will fail after pretty exactly 232 runs. (I have also seen 231 and 233.) // If I don't close the pty, after 30 (running out of ptys). // So I am running out of something else. What? --- This shows fairly well what I am doing in as few lines as possible, and I wonder what I am doing wrong. There is some kind of resource of which there are only about 232, but it isn't the PTYs themselves. What more is there for me to close? The result of this problem in a full application is, obviously, that after running 232 sub-processes with forkpty, my program will fail. BTW, I am running this under OSX 10.6.7, on a MacBook from 2009 (Core2Duo). /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... This email sent to site_archiver@lists.apple.com
participants (1)
-
ingemar@ragnemalm.se