public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: POSIX msg queues: improve error output in fixup_after_fork Date: Sat, 22 May 2021 16:03:25 +0000 (GMT) [thread overview] Message-ID: <20210522160325.AA6D83858024@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=49b84cb264c3be68d8e15f8ccde28a92410a7c0c commit 49b84cb264c3be68d8e15f8ccde28a92410a7c0c Author: Corinna Vinschen <corinna@vinschen.de> Date: Fri May 21 17:47:14 2021 +0200 Cygwin: POSIX msg queues: improve error output in fixup_after_fork Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/fhandler_mqueue.cc | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/fhandler_mqueue.cc b/winsup/cygwin/fhandler_mqueue.cc index 06ccf2f1e..6fc17c28c 100644 --- a/winsup/cygwin/fhandler_mqueue.cc +++ b/winsup/cygwin/fhandler_mqueue.cc @@ -136,28 +136,35 @@ fhandler_mqueue::fixup_after_fork (HANDLE parent) SIZE_T filesize = mqinfo ()->mqi_sectsize; NTSTATUS status; - DuplicateHandle (parent, mqinfo ()->mqi_sect, - GetCurrentProcess (), &mqinfo ()->mqi_sect, - 0, FALSE, DUPLICATE_SAME_ACCESS); + if (!DuplicateHandle (parent, mqinfo ()->mqi_sect, + GetCurrentProcess (), &mqinfo ()->mqi_sect, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + __leave; status = NtMapViewOfSection (mqinfo ()->mqi_sect, NtCurrentProcess (), &mptr, 0, filesize, NULL, &filesize, ViewShare, 0, PAGE_READWRITE); if (!NT_SUCCESS (status)) - api_fatal ("Mapping message queue failed in fork\n"); - else - mqinfo ()->mqi_hdr = (struct mq_hdr *) mptr; - DuplicateHandle (parent, mqinfo ()->mqi_waitsend, - GetCurrentProcess (), &mqinfo ()->mqi_waitsend, - 0, FALSE, DUPLICATE_SAME_ACCESS); - DuplicateHandle (parent, mqinfo ()->mqi_waitrecv, - GetCurrentProcess (), &mqinfo ()->mqi_waitrecv, - 0, FALSE, DUPLICATE_SAME_ACCESS); - DuplicateHandle (parent, mqinfo ()->mqi_lock, - GetCurrentProcess (), &mqinfo ()->mqi_lock, - 0, FALSE, DUPLICATE_SAME_ACCESS); + api_fatal ("Mapping message queue failed in fork, status 0x%x\n", + status); + + mqinfo ()->mqi_hdr = (struct mq_hdr *) mptr; + if (!DuplicateHandle (parent, mqinfo ()->mqi_waitsend, + GetCurrentProcess (), &mqinfo ()->mqi_waitsend, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + __leave; + if (!DuplicateHandle (parent, mqinfo ()->mqi_waitrecv, + GetCurrentProcess (), &mqinfo ()->mqi_waitrecv, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + __leave; + if (!DuplicateHandle (parent, mqinfo ()->mqi_lock, + GetCurrentProcess (), &mqinfo ()->mqi_lock, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + __leave; + return; } __except (EFAULT) {} __endtry + api_fatal ("Creating IPC object failed in fork, %E"); } int
reply other threads:[~2021-05-22 16:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210522160325.AA6D83858024@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).