View Issue Details

IDProjectCategoryView StatusLast Update
0001809Issue 8 draftsSystem Interfacespublic2024-04-11 16:26
Reporteralanc Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status ResolvedResolutionAccepted As Marked 
Product VersionDraft 4 
NameAlan Coopersmith
OrganizationOracle Solaris Engineering
User Reference
Sectionclose()
Page Number747
Line Number25797-25799
Final Accepted Text0001809:0006748
Summary0001809: close() guidance to use fclose() should also discuss fdopen()
DescriptionIn the Application Usage section for close(), it currently states:

An application that had used the stdio routine fopen() to open a file should
use the corresponding fclose() routine rather than close(). Once a file is
closed, the file descriptor no longer exists, since the integer corresponding
to it no longer refers to a file.

Nothing I see currently gives similar guidance for what to do after using
fdopen() so that users know that once they've called fdopen() on an fd
they must now use fclose() and not just close() the underlying fd out from
under stdio.
Desired ActionChange the first sentence to something like:

An application that had used the stdio routine fopen() to open a file,
or that had used fdopen() to create a stdio stream for an existing file
descriptor, should use the corresponding fclose() routine rather than close().

And possibly add similar text to the fdopen() Application Usage section.
Tagstc1-2024

Relationships

related to 0001810 Resolved fdopen() can only be used once per file descriptor 

Activities

alanc

2024-02-10 17:42

reporter   bugnote:0006649

Apologies, I selected the wrong version when filing, this should have been
filed against Issue 8, Draft 4.

Don Cragun

2024-02-10 18:54

manager   bugnote:0006650

This issue has been moved as requested by 0001809:0006649.

geoffclare

2024-04-11 16:25

manager   bugnote:0006748

Change:
An application that had used the stdio routine fopen() to open a file should use the corresponding fclose() routine rather than close(). Once a file is closed, the file descriptor no longer exists, since the integer corresponding to it no longer refers to a file.

to:
If the file descriptor is associated with a standard I/O stream (for example, if the file descriptor was obtained by calling fileno() on a stream, or if an associated stream was created using fdopen()), the file descriptor should be closed using fclose() on the associated stream (or pclose() if the stream was opened using popen()) instead of calling close() or posix_close() on the file descriptor. Once a file descriptor is closed, the integer corresponding to it no longer refers to a file. However, the same integer can be allocated on a subsequent file open and would then become associated with the stream if the stream has not been closed.

If the file descriptor is associated with a directory stream (for example, if the file descriptor was obtained by calling dirfd() on a directory stream, or if a directory stream was created using fdopendir()), the file descriptor should be closed using closedir() on the associated directory stream instead of calling close() or posix_close() on the file descriptor.

Issue History

Date Modified Username Field Change
2024-02-10 17:34 alanc New Issue
2024-02-10 17:34 alanc Name => Alan Coopersmith
2024-02-10 17:34 alanc Organization => Oracle Solaris Engineering
2024-02-10 17:34 alanc Section => close()
2024-02-10 17:34 alanc Page Number => 747
2024-02-10 17:34 alanc Line Number => 25797-25799
2024-02-10 17:42 alanc Note Added: 0006649
2024-02-10 18:53 Don Cragun Project 1003.1(2013)/Issue7+TC1 => Issue 8 drafts
2024-02-10 18:54 Don Cragun Note Added: 0006650
2024-02-10 18:54 Don Cragun Product Version => Draft 4
2024-02-10 18:57 Don Cragun Relationship added related to 0001810
2024-04-11 16:25 geoffclare Note Added: 0006748
2024-04-11 16:26 geoffclare Final Accepted Text => 0001809:0006748
2024-04-11 16:26 geoffclare Status New => Resolved
2024-04-11 16:26 geoffclare Resolution Open => Accepted As Marked
2024-04-11 16:27 geoffclare Tag Attached: tc1-2024