diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e132577a5..c93eeba37 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2014-12-02 Corinna Vinschen + + * flock.cc (create_lock_in_parent): Make lf_obj handle inheritable. + Explain why. + (lockf_t::create_lock_obj): Use FALSE, rather than 0 for BOOL argument. + (lockf_t::del_lock_obj): Check if NtSetEvent succeeded and print system + message if not. + 2014-12-02 Corinna Vinschen * uinfo.cc (fetch_windows_home): New function fetching Windows-compliant diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index 540d914e3..783bf327d 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -703,6 +703,12 @@ create_lock_in_parent (PVOID param) NtClose (lf_obj); return 0; } + /* The handle gets created non-inheritable. That's fine, unless the parent + starts another process accessing this object. So, after it's clear we + have to store the handle for further use, make sure it gets inheritable + by child processes. */ + if (!SetHandleInformation (lf_obj, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) + goto err; /* otherwise generate inode from directory name... */ node = inode_t::get (dev, ino, true, false); /* ...and generate lock from object name. */ @@ -810,7 +816,7 @@ lockf_t::create_lock_obj () return; } if (!DuplicateHandle (GetCurrentProcess (), lf_obj, parent_proc, - &parent_lf_obj, TRUE, 0, DUPLICATE_SAME_ACCESS)) + &parent_lf_obj, TRUE, FALSE, DUPLICATE_SAME_ACCESS)) debug_printf ("DuplicateHandle (lf_obj): %E"); else { @@ -873,7 +879,9 @@ lockf_t::del_lock_obj (HANDLE fhdl, bool signal) if ((lf_flags & F_POSIX) || signal || (fhdl && get_obj_handle_count (fhdl) <= 1)) { - NtSetEvent (lf_obj, NULL); + NTSTATUS status = NtSetEvent (lf_obj, NULL); + if (!NT_SUCCESS (status)) + system_printf ("NtSetEvent, %y", status); /* For BSD locks, notify the parent process. */ if (lf_flags & F_FLOCK) { diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index a0686c5d8..9f9c349db 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -467,6 +467,7 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, } } +debug_printf ("ping 1"); if (mode == _P_DETACH) c_flags |= DETACHED_PROCESS; else