standards/171572: ptsname(-1) returns errno 0
Sergey Kandaurov
pluknet at gmail.com
Wed Sep 12 14:10:07 UTC 2012
The following reply was made to PR standards/171572; it has been noted by GNATS.
From: Sergey Kandaurov <pluknet at gmail.com>
To: Ed Maste <emaste at freebsd.org>
Cc: bug-followup at freebsd.org
Subject: Re: standards/171572: ptsname(-1) returns errno 0
Date: Wed, 12 Sep 2012 18:07:16 +0400
On 12 September 2012 17:53, Ed Maste <emaste at freebsd.org> wrote:
> On 12 September 2012 09:40, Sergey Kandaurov <pluknet at gmail.com> wrote:
>> This is regression (or was it an intended change?) from 8.x's MPSAFE TTY:
>>
>> in 8.x ptsname() was changed so that:
>> /* Make sure ptsname() does not overwrite errno. */
>
> It looks like it was intentional, probably based on:
>
> http://pubs.opengroup.org/onlinepubs/007904975/functions/ptsname.html:
>
> ERRORS
>
> No errors are defined
>
> I guess this was interpreted as "shall not set errno."
>
> However - http://austingroupbugs.net/view.php?id=503:
>
> At line 54750, after "shall return a null pointer", add ", and may set errno".
>
> At line 54754, replace "No errors are defined." with:
>
> The ptsname( ) function may fail if:
> [EBADF] The fildes argument is not a valid file descriptor.
> [ENOTTY] The file associated with the fildes argument is not a master
> pseudo-terminal device..
>
> There's some further discussion on ENOTTY vs EINVAL there. It looks
> like we should at least set errno though:
Oh, well in 7.x before MPSAFE TTY ptsname() used to return:
[EINVAL] fildes is not a master pseudo-terminal device.
and the errors specified for the fstat(2) system call.
Probably the only we should change is to turn EINVAL into ENOTTY for !master pt
(change __isptmaster()) and return errors from fstat() as is if any.
--
wbr,
pluknet
More information about the freebsd-standards
mailing list