From: mike AT mbsun DOT mlb DOT org (Mike Bernson) Subject: Problem with fork 13 Apr 1997 17:31:35 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <33516B33.6201DD56.cygnus.gnu-win32@mbsun.mlb.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.01 (X11; I; BSD/OS 3.0 i386) Original-To: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com I am getting a permision problem when trying to fork. Does anyone known why I would get a EACCES from fork system call. Is there any way to findout what it trying to get access to. I am using thing under window 95. #include #include #include #include #include #include #include #include #include "tol.h" #define max(a,b) ((a) > (b) ? (a) : (b)) int execute(file_name, args) char *file_name; char *args[]; { int status; pid_t pid; int i; int fd_max; fd_max = 20; /* * Loop trying to fork until we are able to do so. If the * fork fails then sleep some random amount of time between * 5 and 36 seconds. */ do { /* * Create a process and do the right thing for parent. * child, and errors */ switch(pid = fork()) { /* * error creating new child/process. Log an error message * and sleep for a random amount of time. */ case -1: log_it("execute: fork failed %s", strerror(errno)); sleep((rand() & 0x1f) + 5); break; /* * child process. Close all the open file expect stdin, * stdout, stderr. Once this is done the execute the * new program. */ case 0: for(i=3; i < fd_max; i++) close(i); execvp(file_name, args); _exit(100 + errno); /* * parent task. Wait for the child to exit and then collect * exit status of child. If exist status greater then 100 * then the child did not run. */ default: status = 1; waitpid(pid, &status, 0); if (WEXITSTATUS(status) > 100) log_it("execute: Could not execute %s(%s)\n", file_name, strerror(WEXITSTATUS(status) - 100)); } } while(pid < 0); /* * Let caller known if the child run and executed ok. */ if ((WIFSIGNALED((status)))) { log_it ("execute: %s died with signal\n", file_name); return -1; } if (!WIFEXITED(status) ) { log_it ("execute: %s did not call exit\n", file_name); return -1; } if (WEXITSTATUS(status) != 0) return -1; else return 0; } - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".