A NOTE has been added to this issue. 
====================================================================== 
https://austingroupbugs.net/view.php?id=1493 
====================================================================== 
Reported By:                geoffclare
Assigned To:                
====================================================================== 
Project:                    1003.1(2016/18)/Issue7+TC2
Issue ID:                   1493
Category:                   Shell and Utilities
Type:                       Enhancement Request
Severity:                   Comment
Priority:                   normal
Status:                     New
Name:                       Geoff Clare 
Organization:               The Open Group 
User Reference:              
Section:                    2.7 
Page Number:                2360 
Line Number:                75306 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2021-07-29 14:33 UTC
Last Modified:              2021-07-29 16:49 UTC
====================================================================== 
Summary:                    move XCU 2.7 definition of "file descriptor" into
XBD 3
====================================================================== 

---------------------------------------------------------------------- 
 (0005422) kre (reporter) - 2021-07-29 16:49
 https://austingroupbugs.net/view.php?id=1493#c5422 
---------------------------------------------------------------------- 
I have no problem with this change in general, though there are a
couple of wording changes (just cleanups) I'll suggest in some later
note if no-one else gets there first, but this part:

   The file descriptor underlying stdin is initially 0; this cannot
   change through the use of interfaces defined in this standard,

(and the similar limitations expresseed for stdout and stderr) looks
to be simply wrong to me.   I'm also not sure there's any need to
actually make this point, even if it were true.

But consider

     close(fileno(stdin));
     fd = open("/dev/null", 0);
     freopen("/my/file", "r", stdin);

(use fdopen() instead of open() if you prefer, but not fclose() as
any use of any stream after it has been fclose'd is undefined, as its
data struct may have been discarded).

I'm not sure what file descriptor you expect freopen() to assign in
that case (assuming the open of /my/file succeeds, etc, of course),
but it isn't usually going to be 0, and this is using only interfaces
defined by the standard, I believe.

Note that freopen() specifically says:

    If pathname is not a null pointer, freopen() shall close any file
    descriptor associated with stream. Failure to close the file
descriptor
    successfully shall be ignored.

That is, freopen() is defined to work properly if the file descriptor has
already been closed (some systems may have other reasons for the close
failing,
allowing for a different fd to be returned from the open, but that would
be
using something beyond the standard interfaces I think). 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2021-07-29 14:33 geoffclare     New Issue                                    
2021-07-29 14:33 geoffclare     Name                      => Geoff Clare     
2021-07-29 14:33 geoffclare     Organization              => The Open Group  
2021-07-29 14:33 geoffclare     Section                   => 2.7             
2021-07-29 14:33 geoffclare     Page Number               => 2360            
2021-07-29 14:33 geoffclare     Line Number               => 75306           
2021-07-29 14:33 geoffclare     Interp Status             => ---             
2021-07-29 16:49 kre            Note Added: 0005422                          
======================================================================


  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [1003.1... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [1003.1... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [1003.1... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [1003.1... Austin Group Bug Tracker via austin-group-l at The Open Group
    • [1003.1... Austin Group Bug Tracker via austin-group-l at The Open Group

Reply via email to