]> git.ipfire.org Git - thirdparty/man-pages.git/commit
ptsname.3: Fix description of failure behaviour of ptsname_r()
authorBruno Haible <bruno@clisp.org>
Sat, 26 Jan 2019 13:31:56 +0000 (14:31 +0100)
committerMichael Kerrisk <mtk.manpages@gmail.com>
Sat, 25 Apr 2020 19:44:06 +0000 (21:44 +0200)
commit8d4d268f0e23ad54f1c26eaa51aec13de9f865d8
tree8d2ee0a1b42577fefebd4a372aa9d12b19e918c7
parentc6364a1b33cb090394f1befe2f8643ca2225216a
ptsname.3: Fix description of failure behaviour of ptsname_r()

The Linux man page for ptsname_r, when describing the behaviour
in the error case, is
  - not consistent with the future POSIX standard (POSIX Issue 8).
  - not consistent with musl libc.

Find attached a patch to
  - keep it consistent with what glibc does,
  - make it consistent with musl libc,
  - make it consistent with the future POSIX standard (POSIX
    Issue 8).

Details:

glibc's implementation of ptsname_r, when it fails, returns the
error code as return value AND sets errno. See
https://sourceware.org/git/?p=glibc.git;a=blob;f=login/ptsname.c
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/mach/hurd/ptsname.c
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/ptsname.c

musl's implementation of ptsname_r, when it fails, returns the error code
but does NOT set errno. See
https://git.musl-libc.org/cgit/musl/tree/src/misc/pty.c

The proposal to add ptsname_r to POSIX, with text

  "If successful, the ptsname_r( ) function shall return zero.
   Otherwise, an error number shall be returned to indicate the
   error."

has been accepted for inclusion in POSIX Issue 8.
http://austingroupbugs.net/view.php?id=508

Therefore a portable program should look at the return value from
ptsname_r, NOT the errno value. The current text in the man page
suggests to look at the errno value, which is wrong (because of
musl libc) and not future-proof (because of future POSIX).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
man3/ptsname.3