Cygwin: FIFO: take ownership on exec

If fixup_after_exec is called on a non-close-on-exec reader whose
parent is the owner, transfer ownership to the child.  Otherwise the
parent's pipe handles will be closed before any other reader can
duplicate them.

To help with this, make the cancel_evt and thr_sync_evt handles
inheritable, so that the child can terminate the parent's
fifo_reader_thread (and the parent will update the shared fc_handler
list).

Add an optional argument 'from_exec' to update_my_handlers to simplify
its use in this case; no handle duplication is required.
This commit is contained in:
Ken Brown
2020-04-23 21:29:32 -04:00
parent d9918451e2
commit 39a9cd9465
2 changed files with 110 additions and 49 deletions

View File

@ -1414,7 +1414,7 @@ class fhandler_fifo: public fhandler_base
{ return shmem->get_shared_fc_handler_committed (); }
void set_shared_fc_handler_committed (size_t n)
{ shmem->set_shared_fc_handler_committed (n); }
int update_my_handlers ();
int update_my_handlers (bool from_exec = false);
int update_shared_handlers ();
public: