From 1dde4c3cfcea28c020a1a2d0aca6e7cde45cf2ad Mon Sep 17 00:00:00 2001 From: cgf Date: Fri, 14 Jul 2006 22:15:12 +0000 Subject: [PATCH] * fork.cc (fork): Lock the process before forking to prevent things like new fds from being opened, etc. * sync.h (lock_process::dont_bother): New function. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/fork.cc | 6 +++++- winsup/cygwin/sync.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a292b9537e..cf8ac0a652 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2006-07-14 Christopher Faylor + * fork.cc (fork): Lock the process before forking to prevent things + like new fds from being opened, etc. + * sync.h (lock_process::dont_bother): New function. + +2006-07-14 Christopher Faylor + * include/cygwin/types.h: Update copyright. 2006-07-14 Christopher Faylor diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 2043629114..ed85e74cf0 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -533,6 +533,7 @@ fork () return -1; } + lock_process now; if (sig_send (NULL, __SIGHOLD)) { if (exit_state) @@ -547,7 +548,10 @@ fork () __asm__ volatile ("movl %%esp,%0": "=r" (esp)); if (ischild) - res = grouped.child (esp); + { + res = grouped.child (esp); + now.dont_bother (); + } else { res = grouped.parent (esp); diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h index 8fd01df3a1..f7ce7e1b4b 100644 --- a/winsup/cygwin/sync.h +++ b/winsup/cygwin/sync.h @@ -50,6 +50,7 @@ class lock_process static muto locker; public: static void init () {locker.init ("lock_process");} + void dont_bother () {skip_unlock = true;} lock_process (bool exiting = false) { locker.acquire (); -- 2.11.0