From f9fb1149d5b1c0c15f9a554677019dbc5426ed83 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 2 Jun 2005 02:36:50 +0000 Subject: [PATCH] Revert 2005-05-30 close_all_files changes. * spawn.cc (spawn_guts): When execing, close all files after the child has synced with us. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/cygheap.cc | 5 ++++- winsup/cygwin/dcrt0.cc | 2 +- winsup/cygwin/dtable.cc | 2 +- winsup/cygwin/dtable.h | 2 +- winsup/cygwin/fhandler.h | 2 +- winsup/cygwin/spawn.cc | 2 +- winsup/cygwin/syscalls.cc | 5 ++--- winsup/cygwin/winsup.h | 2 +- 9 files changed, 18 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9b906aca5..8ab500d0d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2005-06-01 Christopher Faylor + + Revert 2005-05-30 close_all_files changes. + * spawn.cc (spawn_guts): When execing, close all files after the child + has synced with us. + 2005-06-01 Christopher Faylor * fhandler_disk_file.cc (fhandler_disk_file::fchown): Make sure that diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 3d0ce4b1b..48262ca06 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -61,7 +61,10 @@ cygheap_fixup_in_child (bool execed) _csbrk ((char *) child_proc_info->cygheap_max - (char *) cygheap); child_copy (child_proc_info->parent, child_proc_info->dwProcessId, "cygheap", cygheap, cygheap_max); if (execed) - CloseHandle (child_proc_info->parent); + { + CloseHandle (child_proc_info->parent); + child_proc_info->parent = NULL; + } cygheap_init (); debug_fixup_after_fork_exec (); diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index fa407d407..4f643ae1e 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1030,7 +1030,7 @@ do_exit (int status) if (exit_state < ES_CLOSEALL) { exit_state = ES_CLOSEALL; - close_all_files (false); + close_all_files (); } if (exit_state < ES_SIGPROCTERMINATE) diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index db69ed376..24a88ce26 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -766,7 +766,7 @@ dtable::vfork_parent_restore () lock (); fhandler_tty_slave *ctty_on_hold = cygheap->ctty_on_hold; - close_all_files (false); + close_all_files (); fhandler_base **deleteme = fds; fds = fds_on_hold; fds_on_hold = NULL; diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h index 9e0523808..343eb8cc8 100644 --- a/winsup/cygwin/dtable.h +++ b/winsup/cygwin/dtable.h @@ -84,7 +84,7 @@ public: fhandler_base **add_archetype (); void delete_archetype (fhandler_base *); friend void dtable_init (); - friend void __stdcall close_all_files (bool); + friend void __stdcall close_all_files (); friend class cygheap_fdmanip; friend class cygheap_fdget; friend class cygheap_fdnew; diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index f0b588fca..ff2f315e3 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -82,7 +82,7 @@ enum query_state { class fhandler_base { friend class dtable; - friend void close_all_files (bool); + friend void close_all_files (); struct status_flags { diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index db8b4d97d..654b1d454 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -796,7 +796,6 @@ spawn_guts (const char * prog_arg, const char *const *argv, myself.hProcess = hExeced = pi.hProcess; strcpy (myself->progname, real_path); // FIXME: race? sigproc_printf ("new process name %s", myself->progname); - close_all_files (true); /* If wr_proc_pipe doesn't exist then this process was not started by a cygwin process. So, we need to wait around until the process we've just "execed" dies. Use our own wait facility to wait for our own pid to exit (there @@ -865,6 +864,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, switch (mode) { case _P_OVERLAY: + close_all_files (); if (!synced) /* let myself.exit handle this */; else if (myself->wr_proc_pipe) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 022282036..c67bc3799 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -94,7 +94,7 @@ static int __stdcall stat_worker (const char *name, struct __stat64 *buf, ensure we don't leave any such files lying around. */ void __stdcall -close_all_files (bool keep_table) +close_all_files () { cygheap->fdtab.lock (); @@ -106,8 +106,7 @@ close_all_files (bool keep_table) debug_printf ("closing fd %d", i); #endif fh->close (); - if (!keep_table) - cygheap->fdtab.release (i); + cygheap->fdtab.release (i); } if (cygheap->ctty) diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 6145306ed..9d7cc96a5 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -221,7 +221,7 @@ void uinfo_init (void); void events_init (void); void events_terminate (void); -void __stdcall close_all_files (bool); +void __stdcall close_all_files (); /* Globals that handle initialization of winsock in a child process. */ extern HANDLE wsock32_handle;