diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 55f18aebd..90805abb8 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1076,6 +1076,7 @@ class fhandler_socket_unix : public fhandler_socket void fixup_after_fork (HANDLE parent); void fixup_after_exec (); void set_close_on_exec (bool val); + void fixup_helper (); public: fhandler_socket_unix (); diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc index 6f4383861..703781d17 100644 --- a/winsup/cygwin/fhandler_socket_inet.cc +++ b/winsup/cygwin/fhandler_socket_inet.cc @@ -534,7 +534,7 @@ void fhandler_socket_wsock::fixup_after_exec () { if (need_fixup_before () && !close_on_exec ()) - fixup_after_fork (NULL); + fixup_after_fork (NULL); /* No parent handle required. */ } int diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index 760f210bf..d7bb1090e 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -1149,6 +1149,16 @@ fhandler_socket_unix::set_cred () scred->gid = myself->gid; } +void +fhandler_socket_unix::fixup_helper () +{ + if (shmem_handle) + reopen_shmem (); + connect_wait_thr = NULL; + cwt_termination_evt = NULL; + cwt_param = NULL; +} + /* ========================== public methods ========================= */ void @@ -1158,20 +1168,15 @@ fhandler_socket_unix::fixup_after_fork (HANDLE parent) if (backing_file_handle && backing_file_handle != INVALID_HANDLE_VALUE) fork_fixup (parent, backing_file_handle, "backing_file_handle"); if (shmem_handle) - { - fork_fixup (parent, shmem_handle, "shmem_handle"); - reopen_shmem (); - } - connect_wait_thr = NULL; - cwt_termination_evt = NULL; - cwt_param = NULL; + fork_fixup (parent, shmem_handle, "shmem_handle"); + fixup_helper (); } void fhandler_socket_unix::fixup_after_exec () { if (!close_on_exec ()) - fixup_after_fork (NULL); + fixup_helper (); } void diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 153bdad79..b42e0aeb6 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -2974,7 +2974,7 @@ fhandler_pty_slave::fixup_after_exec () reset_switch_to_pcon (); if (!close_on_exec ()) - fixup_after_fork (NULL); + fixup_after_fork (NULL); /* No parent handle required. */ else if (get_pseudo_console ()) { int used = 0;