diff options
author | Christopher Faylor <me@cgf.cx> | 2001-02-10 04:20:52 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-02-10 04:20:52 +0000 |
commit | cde0c2fbcaac1f78efc607475f6f4bed37e25cfc (patch) | |
tree | 6e60d15e6899611af43fe6f2ff618bf933bf5cc7 /winsup | |
parent | 1e667f61b72db0e8ae2a0f7f037f1824c39aeaf3 (diff) | |
download | newlib-cde0c2fbcaac1f78efc607475f6f4bed37e25cfc.zip newlib-cde0c2fbcaac1f78efc607475f6f4bed37e25cfc.tar.gz newlib-cde0c2fbcaac1f78efc607475f6f4bed37e25cfc.tar.bz2 |
* fork.cc (fork_parent): Return EAGAIN when can't record pid.
* pinfo.h (pinfo::remember): Return value of call to proc_subproc.
* sigproc.cc (proc_subproc): Return error if can't record pid.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/fork.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 5 |
4 files changed, 26 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a5b41cd..194515e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Fri Feb 9 23:19:01 2001 Christopher Faylor <cgf@cygnus.com> + + * fork.cc (fork_parent): Return EAGAIN when can't record pid. + * pinfo.h (pinfo::remember): Return value of call to proc_subproc. + * sigproc.cc (proc_subproc): Return error if can't record pid. + Fri Feb 9 12:17:27 2001 Christopher Faylor <cgf@cygnus.com> * syscalls.cc (mknod): Add valid parameters. diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 7e8ad53..8a1daf7 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -514,13 +514,24 @@ out: be called in subproc handling. */ ProtectHandle1 (pi.hProcess, childhProc); - slow_pid_reuse (pi.hProcess); - /* Fill in fields in the child's process table entry. */ forked->hProcess = pi.hProcess; forked->dwProcessId = pi.dwProcessId; forked->copysigs(myself); - forked.remember (); + + /* Hopefully, this will succeed. The alternative to doing things this + way is to reserve space prior to calling CreateProcess and then fill + it in afterwards. This requires more bookkeeping than I like, though, + so we'll just do it the easy way. So, terminate any child process if + we can't actually record the pid in the internal table. */ + if (!forked.remember ()) + { + TerminateProcess (pi.hProcess, 1); + set_errno (EAGAIN); + goto cleanup; + } + + slow_pid_reuse (pi.hProcess); /* Wait for subproc to initialize itself. */ if (!sync_with_child(pi, subproc_ready, TRUE, "waiting for longjmp")) diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index dd49cd8..2be2623 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -18,7 +18,7 @@ enum __SIGOFFSET = 3 }; -#define PSIZE 1024 +#define PSIZE 63 #include <sys/resource.h> #include "thread.h" @@ -152,7 +152,7 @@ public: _pinfo *operator * () const {return procinfo;} operator _pinfo * () const {return procinfo;} // operator bool () const {return (int) h;} - void remember () {destroy = 0; proc_subproc (PROC_ADDCHILD, (DWORD) this);} + int remember () {destroy = 0; return proc_subproc (PROC_ADDCHILD, (DWORD) this);} HANDLE shared_handle () {return h;} }; diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index ac1eaf5..43be57e 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -246,7 +246,10 @@ proc_subproc (DWORD what, DWORD val) */ case PROC_ADDCHILD: if (nchildren >= PSIZE - 1) - system_printf ("nchildren too large %d", nchildren); + { + rc = 0; + break; + } pchildren[nchildren] = vchild; hchildren[nchildren] = vchild->hProcess; if (!DuplicateHandle (hMainProc, vchild->hProcess, hMainProc, &vchild->pid_handle, |