public inbox for
 help / color / mirror / Atom feed
From: Ken Brown <>
Subject: [PATCH] Cygwin: ptsname_r: always return an error number on failure
Date: Wed, 20 Jan 2021 13:00:03 -0500	[thread overview]
Message-ID: <> (raw)

Following Linux, return ENOTTY on a bad file descriptor and also set
errno to ENOTTY.

Previously 0 was returned and errno was set to EBADF.  Returning 0
violates the requirement in that an error
number should be returned on failure.  (That man page doesn't specify
setting errno.)

 winsup/cygwin/release/3.2.0 | 3 +++
 winsup/cygwin/   | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index 43725cec2..f748a9bc8 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -52,3 +52,6 @@ Bug Fixes
 - Fix the errno when a path contains .. and the prefix exists but is
   not a directory.
+- Fix the return value when ptsname_r(3) is called with a bad file descriptor
+  Addresses:
diff --git a/winsup/cygwin/ b/winsup/cygwin/
index 4742c6653..18d9e3f88 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
@@ -3364,7 +3364,10 @@ ptsname_r (int fd, char *buf, size_t buflen)
   cygheap_fdget cfd (fd);
   if (cfd < 0)
-    return 0;
+    {
+      set_errno (ENOTTY);
+      return ENOTTY;
+    }
   return cfd->ptsname_r (buf, buflen);

             reply	other threads:[~2021-01-20 18:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 18:00 Ken Brown [this message]
2021-01-21 22:48 ` Ken Brown
2021-01-22  9:44   ` Corinna Vinschen

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be 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).