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: timerfd/signalfd: return EINVAL from write Date: Thu, 17 Jan 2019 10:51:00 -0000 [thread overview] Message-ID: <20190117105119.92816.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7f983079d4a62e3f906a97bf091908a1dad29bb6 commit 7f983079d4a62e3f906a97bf091908a1dad29bb6 Author: Corinna Vinschen <corinna@vinschen.de> Date: Thu Jan 17 11:51:11 2019 +0100 Cygwin: timerfd/signalfd: return EINVAL from write Linux returns EINVAL, "fd is attached to an object which is unsuitable for writing". If we don't handle write locally, write returns EBADF. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/fhandler.h | 2 ++ winsup/cygwin/fhandler_signalfd.cc | 8 ++++++++ winsup/cygwin/fhandler_timerfd.cc | 17 +++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index f0c612d..497612a 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -2650,6 +2650,7 @@ class fhandler_signalfd : public fhandler_base int signalfd (const sigset_t *mask, int flags); int __reg2 fstat (struct stat *buf); void __reg3 read (void *ptr, size_t& len); + ssize_t __stdcall write (const void *, size_t); int poll (); inline sigset_t get_sigset () const { return sigset; } @@ -2693,6 +2694,7 @@ class fhandler_timerfd : public fhandler_base int __reg2 fstat (struct stat *buf); void __reg3 read (void *ptr, size_t& len); + ssize_t __stdcall write (const void *, size_t); int dup (fhandler_base *child, int); int ioctl (unsigned int, void *); int close (); diff --git a/winsup/cygwin/fhandler_signalfd.cc b/winsup/cygwin/fhandler_signalfd.cc index d8e17a8..6c7da02 100644 --- a/winsup/cygwin/fhandler_signalfd.cc +++ b/winsup/cygwin/fhandler_signalfd.cc @@ -49,6 +49,7 @@ fhandler_signalfd::signalfd (const sigset_t *mask, int flags) nohandle (true); set_unique_id (); set_ino (get_unique_id ()); + set_flags (O_RDWR | O_BINARY); } return 0; } @@ -139,6 +140,13 @@ fhandler_signalfd::read (void *ptr, size_t& len) return; } +ssize_t __stdcall +fhandler_signalfd::write (const void *, size_t) +{ + set_errno (EINVAL); + return -1; +} + /* Called from select */ int fhandler_signalfd::poll () diff --git a/winsup/cygwin/fhandler_timerfd.cc b/winsup/cygwin/fhandler_timerfd.cc index 360731c..c7ff9c1 100644 --- a/winsup/cygwin/fhandler_timerfd.cc +++ b/winsup/cygwin/fhandler_timerfd.cc @@ -44,12 +44,10 @@ fhandler_timerfd::timerfd (clockid_t clock_id, int flags) set_nonblocking (true); if (flags & TFD_CLOEXEC) set_close_on_exec (true); - if (get_unique_id () == 0) - { - nohandle (true); - set_unique_id (); - set_ino (get_unique_id ()); - } + nohandle (true); + set_unique_id (); + set_ino (get_unique_id ()); + set_flags (O_RDWR | O_BINARY); return 0; } @@ -125,6 +123,13 @@ fhandler_timerfd::read (void *ptr, size_t& len) return; } +ssize_t __stdcall +fhandler_timerfd::write (const void *, size_t) +{ + set_errno (EINVAL); + return -1; +} + HANDLE fhandler_timerfd::get_timerfd_handle () {
reply other threads:[~2019-01-17 10:51 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=20190117105119.92816.qmail@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).