View Issue Details

IDProjectCategoryView StatusLast Update
00003701003.1(2008)/Issue 7System Interfacespublic2024-06-11 08:53
Reportereblake Assigned Toajosey  
PrioritynormalSeverityObjectionTypeError
Status ClosedResolutionAccepted As Marked 
NameEric Blake
OrganizationRed Hat
User Referenceebb.posix_spawn
Sectionposix_spawn_file_actions_addclose
Page Number1430
Line Number46882
Interp StatusApproved
Final Accepted TextSee 0000370:0000718
Summary0000370: addclose should not cause posix_spawn to fail if closing an already closed fd
DescriptionRight now, the standard requires posix_spawn to fail if any action registered
by posix_spawn_file_actions fails. However, in the case of close() on an
already closed file descriptor, this is unintentionally harsh.

The problem can be worked around by using adddup2 prior to addclose to ensure
that the close will be on a valid file descriptor, but this adds extra work.
Desired ActionAt line 46673 [XSH posix_spawn], change:

fails for any of the reasons that would cause close( ), dup2( ), or open( ) to
fail, an error value shall be returned

to:

fails for any of the reasons that would cause close( ), dup2( ), or open( ) to
fail, other than attempting a close( ) on a file descriptor that is in range
but already closed, an error value shall be returned

At line 46880 [XSH posix_spawn_file_actions_add_close], change:

The posix_spawn_file_actions_addclose( ) function shall add a close action
to the object referenced by file_actions that shall cause the file
descriptor fildes to be closed (as if close(fildes) had been called) when
a new process is spawned using this file actions object.

to:

The posix_spawn_file_actions_addclose( ) function shall add a close action
to the object referenced by file_actions that shall cause the file
descriptor fildes to be closed (as if close(fildes) had been called) when
a new process is spawned using this file actions object, except that a
nonnegative filedes less than OPEN_MAX that is already closed at the time
when the new process is spawned shall be ignored rather than failing with
EBADF.
Tagsissue8

Relationships

related to 0000149 Closedajosey Add fdwalk system interface 
related to 0000418 Closedajosey posix_spawn_file_actions_addclose() should not check against OPEN_MAX 

Activities

Don Cragun

2011-03-24 15:16

manager   bugnote:0000718

Last edited: 2011-04-28 15:34

Interpretation response
------------------------
The standard states that posix_spawn() must fail with an EBADF error if a request is made to close a file descriptor that is already closed, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
There are existing implementations that behave this way and there is no reason why this should be disallowed.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
Make the changes presented in the Desired Action section plus the changes suggested in 0000370:0000745.

ajosey

2011-03-25 05:51

manager   bugnote:0000724

This proposed interpretation is being circulated for a 30 day review

eblake

2011-04-20 15:03

manager   bugnote:0000745

An additional change is required:

At line 123287 [XRAT B.3.3 Examples for Spawn], change:

if (close(fd) == -1)

to:

if (close(fd) == -1 && errno != EBADF)

ajosey

2011-05-05 20:09

manager   bugnote:0000779

The interpretation is now approved.

Issue History

Date Modified Username Field Change
2011-01-13 16:48 eblake New Issue
2011-01-13 16:48 eblake Status New => Under Review
2011-01-13 16:48 eblake Assigned To => ajosey
2011-01-13 16:48 eblake Name => Eric Blake
2011-01-13 16:48 eblake Organization => Red Hat
2011-01-13 16:48 eblake User Reference => ebb.posix_spawn
2011-01-13 16:48 eblake Section => posix_spawn_file_actions_addclose
2011-01-13 16:48 eblake Page Number => 1430
2011-01-13 16:48 eblake Line Number => 46882
2011-01-13 16:48 eblake Interp Status => ---
2011-01-13 17:04 Don Cragun Status Under Review => Resolved
2011-01-13 17:04 Don Cragun Resolution Open => Accepted
2011-01-13 17:04 Don Cragun Tag Attached: issue8
2011-01-13 17:05 Don Cragun Relationship added related to 0000149
2011-03-24 15:16 Don Cragun Interp Status --- => Pending
2011-03-24 15:16 Don Cragun Note Added: 0000718
2011-03-24 15:16 Don Cragun Status Resolved => Interpretation Required
2011-03-24 15:17 Don Cragun Final Accepted Text => See 0000370:0000718
2011-03-25 05:51 ajosey Interp Status Pending => Proposed
2011-03-25 05:51 ajosey Note Added: 0000724
2011-04-20 15:03 eblake Note Added: 0000745
2011-04-28 15:34 Don Cragun Note Edited: 0000718
2011-04-28 15:34 Don Cragun Resolution Accepted => Accepted As Marked
2011-05-05 20:09 ajosey Interp Status Proposed => Approved
2011-05-05 20:09 ajosey Note Added: 0000779
2011-06-02 16:10 eblake Relationship added related to 0000418
2020-02-14 15:38 geoffclare Status Interpretation Required => Applied
2024-06-11 08:53 agadmin Status Applied => Closed