Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000508 [1003.1(2008)/Issue 7] System Interfaces Objection Enhancement Request 2011-11-10 21:26 2020-03-05 15:25
Reporter eblake View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Applied  
Name Eric Blake
Organization Red Hat
User Reference ebb.ptsname_r
Section ptsname
Page Number 1712
Line Number 54741
Interp Status ---
Final Accepted Text See Note: 0001248
Summary 0000508: Add ptsname_r
Description The standard lacks any simple thread-safe mechanism for determining the
name of the slave of a pseudo-terminal device after obtaining the master
side. [A not-so-simple mechanism for a multi-threaded application in
possession of a master pseudo-terminal file descriptor would be spawning
off a child application that can then use ptsname() in a single-threaded
context, and pass information back to the parent process, but that is
obviously inefficient and complex.]

This proposal is modeled after the ptsname_r() interface present in at
least glibc, and using ttyname() vs. ttyname_r() as the reference for
how to expand the existing ptsname() interface to also cover a
thread-safe alternative. This proposal assumes 0000503 has been
applied first.

Optionally, since ptsname( ) is very similar to ttyname( ), and ttyname( )
is allowed to be a cancellation point, it would make sense to allow both
ptsname( ) and ptsname_r( ) to be cancellation points.
Desired Action After line 12013 [XBD <stdlib.h>], add with XSI shading:

int ptsname_r(int, char *, size_t);

At line 46510 [XSH posix_openpt RATIONALE], change:

The posix_openpt( ) function is designed to complement the
grantpt( ), ptsname( ), and unlockpt( ) functions.

to:

The posix_openpt( ) function is designed to complement the
grantpt( ), ptsname( ), ptsname_r( ), and unlockpt( ) functions.

At line 54738 [XSH ptsname() NAME], change "ptsname" to
"ptsname, ptsname_r"

After line 54741 [SYNOPSIS], add with XSI shading:

int ptsname_r(int fildes, char *name, size_t namesize);

After line 54747 [DESCRIPTION], add:

The ptsname_r( ) function shall store the name of the slave
pseudo-terminal device corresponding to fildes in the character
array referenced by name. The array is namesize characters long and
should have space for the name and the terminating null character.
The maximum length of the terminal name shall be {TTY_NAME_MAX}.

After line 54752 [RETURN VALUE], add:

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

At line 54754 [ERRORS], change this text (from 0000503):

The ptsname( ) function may fail if:
[EBADF] The fildes argument is not a valid file descriptor.
[EINVAL] or [ENOTTY] The filedes argument is not associated with a
master pseudo-terminal device.

to:

The ptsname_r( ) function shall fail if:
[EBADF] The fildes argument is not a valid file descriptor.
[EINVAL] The name argument is a null pointer.
[ERANGE] The value of namesize is smaller than the length of the string
to be returned including the terminating null character.

The ptsname( ) function may fail if:
[EBADF] The fildes argument is not a valid file descriptor.

The ptsname( ) and ptsname_r( ) functions may fail if:
[EINVAL] or [ENOTTY] The filedes argument is not associated with a
master pseudo-terminal device.

At line 54760 [RATIONALE], change "None." to:

The ptsname_r( ) is required to make it possible for a multi-threaded
program to safely determine the name of a slave device. Although the
name of the device is constrained by {TTY_NAME_MAX}, this value might
not be a compile-time constant, so an application can rely on repeated
calls with successively larger buffers until the result is no longer
ERANGE as an alternative for properly sizing the buffer.

Historically, some versions of ptsname( ) did not set errno even when
returning NULL. However, ptsname_r( ) is required to either populate
the buffer with a valid name or return an error value.

After line 126740 [XRAT E.1 Subprofiling Option Groups], add a new
sub-profiling group:

XSI_GENERAL_TERMINAL_R: XSI Thread-Safe General Terminal
ptsname_r( )


Additional editorial changes, such as listing ptsname_r( ) in XRAT B.1.1
Change History, will be needed as appropriate.



Optionally:
At line 17788 [XSH 2.9.5.2 Cancellation Points], add ptsname( ) and
ptsname_r( ) in sorted order into the list of optional cancellation
points.
Tags issue8
Attached Files

- Relationships
related to 0000503Closedajosey ptsname should define optional errno values 
related to 0000075Closedajosey functions that are allowed to overwrite returned static data 
related to 0000618Under Reviewajosey require isatty and friends to set errno on failure 

-  Notes
(0001248)
nick (manager)
2012-05-31 16:07

As described in the Desired Action, with the final "Optionally" required (i.e. add both ptsname() and ptsname_r() to the list of cancellation points).

- Issue History
Date Modified Username Field Change
2011-11-10 21:26 eblake New Issue
2011-11-10 21:26 eblake Status New => Under Review
2011-11-10 21:26 eblake Assigned To => ajosey
2011-11-10 21:26 eblake Name => Eric Blake
2011-11-10 21:26 eblake Organization => Red Hat
2011-11-10 21:26 eblake User Reference => ebb.ptsname_r
2011-11-10 21:26 eblake Section => ptsname
2011-11-10 21:26 eblake Page Number => 1712
2011-11-10 21:26 eblake Line Number => 54741
2011-11-10 21:26 eblake Interp Status => ---
2011-11-10 21:27 eblake Tag Attached: issue8
2011-11-10 21:27 eblake Relationship added related to 0000503
2011-11-10 21:28 eblake Relationship added related to 0000075
2012-05-31 16:03 eblake Desired Action Updated
2012-05-31 16:07 nick Final Accepted Text => See Note: 0001248
2012-05-31 16:07 nick Note Added: 0001248
2012-05-31 16:07 nick Status Under Review => Resolved
2012-05-31 16:07 nick Resolution Open => Accepted As Marked
2012-10-03 03:30 eblake Relationship added related to 0000618
2020-03-05 15:25 geoffclare Status Resolved => Applied
2023-11-05 18:18 emaste Issue Monitored: emaste


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker