diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-12-02 18:39:57 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-12-02 18:39:57 +0300 |
commit | df386ddac898b283aba4aa2f61b513740b1d9393 (patch) | |
tree | 5d6fee0c84a16f7211e0a691e2ed89b6d4d46286 /winsup/cygwin/flock.cc | |
parent | 44cacc7f4409904bcff9438de7c5e5f4f4ceca22 (diff) |
* 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.
Diffstat (limited to 'winsup/cygwin/flock.cc')
-rw-r--r-- | winsup/cygwin/flock.cc | 12 |
1 files changed, 10 insertions, 2 deletions
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) { |