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-10-21 08:53:49 +0400
committerChristopher Faylor <me@cgf.cx>2000-10-21 08:53:49 +0400
commitb0de2aa284ccb58f1c8f8e0a598701b51ab5b742 (patch)
treee9de21c89264e0f9987ab88dab845446c1b4bc45 /winsup/cygwin/fork.cc
parente9921bcbaa37b9c3df39ef1d8182d56a9db3cb11 (diff)
* fhandler.h (fhandler_console): Remove tcsetpgrp.
* fhandler_console.cc (fhandler_console::tcsetpgrp): Eliminate. * fork.cc (fork_parent): Avoid returning same pid twice in a row regardless of OS. * pinfo.cc (pinfo::init): Rename create argument to flags and treat it as such. * signal.cc (set_sigcatchers): New function. (signal): Use set_sigcatchers to increment or decrement sigcatcher tracker. (sigaction): Ditto. Add debugging output. * spawn.cc (spawn_guts): Always quote first argv[0] argument when it's a COMSPEC shell.
Diffstat (limited to 'winsup/cygwin/fork.cc')
-rw-r--r--winsup/cygwin/fork.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index a883ed553..0c8df30cd 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -443,14 +443,17 @@ fork_parent (void *stack_here, HANDLE& hParent, dll *&first_dll, bool& load_dlls
/* Protect the handle but name it similarly to the way it will
be called in subproc handling. */
ProtectHandle1 (pi.hProcess, childhProc);
- if (os_being_run != winNT)
- {
- if (last_fork_proc)
- CloseHandle (last_fork_proc);
- if (!DuplicateHandle (hMainProc, pi.hProcess, hMainProc, &last_fork_proc,
- 0, FALSE, DUPLICATE_SAME_ACCESS))
- system_printf ("couldn't create last_fork_proc, %E");
- }
+
+ /* Keep a handle to the current forked process sitting around to prevent
+ Windows from reusing the same pid twice in a row. Having the same pid
+ twice in a row confuses bash. So, after every CreateProcess, we can safely
+ remove the old pid and save a handle to the newly created process. Keeping
+ a handle open will stop windows from reusing the same pid. */
+ if (last_fork_proc)
+ CloseHandle (last_fork_proc);
+ if (!DuplicateHandle (hMainProc, pi.hProcess, hMainProc, &last_fork_proc,
+ 0, FALSE, DUPLICATE_SAME_ACCESS))
+ system_printf ("couldn't create last_fork_proc, %E");
/* Fill in fields in the child's process table entry. */
forked->ppid = myself->pid;