Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-11-15 09:46:19 +0300
committerChristopher Faylor <me@cgf.cx>2000-11-15 09:46:19 +0300
commit5ba05cab08e2c4b25d6a22219c46e6977d4bd50e (patch)
treed93d4ebf50a738eb41b1099c77d3bf9bb0efcf5c /winsup/cygwin/fork.cc
parent84aeff4126777c437a15c052f08be026f384ab70 (diff)
* fork.cc (slow_pid_reuse): Off-by-one.
Diffstat (limited to 'winsup/cygwin/fork.cc')
-rw-r--r--winsup/cygwin/fork.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index e3ac40475..71da9f544 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -314,19 +314,21 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
static void
slow_pid_reuse (HANDLE h)
{
- static NO_COPY HANDLE last_fork_procs[64];
+ static NO_COPY HANDLE last_fork_procs[64] = {0};
static NO_COPY unsigned nfork_procs = 0;
- if (nfork_procs > (sizeof (last_fork_procs) / sizeof (last_fork_procs [0])))
+ if (nfork_procs >= (sizeof (last_fork_procs) / sizeof (last_fork_procs [0])))
nfork_procs = 0;
/* Keep a list of handles to forked processes sitting around to prevent
Windows from reusing the same pid n times in a row. Having the same pids
close in succesion confuses bash. Keeping a handle open will stop
windows from reusing the same pid. */
if (last_fork_procs[nfork_procs])
- CloseHandle (last_fork_procs[nfork_procs]);
- if (!DuplicateHandle (hMainProc, h, hMainProc, &last_fork_procs[nfork_procs],
+ ForceCloseHandle1 (last_fork_procs[nfork_procs], fork_stupidity);
+ if (DuplicateHandle (hMainProc, h, hMainProc, &last_fork_procs[nfork_procs],
0, FALSE, DUPLICATE_SAME_ACCESS))
+ ProtectHandle1 (last_fork_procs[nfork_procs], fork_stupidity);
+ else
{
last_fork_procs[nfork_procs] = NULL;
system_printf ("couldn't create last_fork_proc, %E");