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
0001809 [Issue 8 drafts] System Interfaces Editorial Clarification Requested 2024-02-10 17:34 2024-04-11 16:26
Reporter alanc View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Resolved   Product Version Draft 4
Name Alan Coopersmith
Organization Oracle Solaris Engineering
User Reference
Section close()
Page Number 747
Line Number 25797-25799
Final Accepted Text Note: 0006748
Summary 0001809: close() guidance to use fclose() should also discuss fdopen()
Description In 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 Action Change 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.
Tags tc1-2024
Attached Files

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

-  Notes
(0006649)
alanc (reporter)
2024-02-10 17:42

Apologies, I selected the wrong version when filing, this should have been
filed against Issue 8, Draft 4.
(0006650)
Don Cragun (manager)
2024-02-10 18:54

This issue has been moved as requested by Note: 0006649.
(0006748)
geoffclare (manager)
2024-04-11 16:25

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 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 => Note: 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


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