mailing list of musl libc
 help / color / mirror / code / Atom feed
* question: hard-coded file descriptors in stdin/stdout/stderr
@ 2013-03-14 16:18 Zvi Gilboa
  2013-03-14 17:17 ` Szabolcs Nagy
  2013-03-18  3:06 ` Rob Landley
  0 siblings, 2 replies; 23+ messages in thread
From: Zvi Gilboa @ 2013-03-14 16:18 UTC (permalink / raw)
  To: musl

Greetings,

I just noticed that the file descriptors in stdin.c, stdout.c, and 
stderr.c do not use the #defines from <unistd.h> (namely STDIN_FILENO, 
STDOUT_FILENO, and STDERR_FILENO), but are rather hard-coded (as 0, 1, 
and 2 respectively).  I was therefore wondering whether there was a 
special reason for that?  With POSIX systems this would normally not be 
an issue, however there are still some systems out there with standard 
file descriptor numbers which are different...

On that same note: wouldn't it make sense to slightly modify unistd.h so 
that it first checks whether STDIN_FILENO, etc. have already been 
defined?  That would allow a system with different standard file 
descriptor numbers to define them in one of the /arch headers, yet 
enable the default for systems that use the "normal" numbers.  The 
relevant section would then read:


#ifndef STDIN_FILENO
   #define STDIN_FILENO  0
#endif

#ifndef STDOUT_FILENO
   #define STDOUT_FILENO 1
#endif

#ifndef STDERR_FILENO
   #define STDERR_FILENO 2
#endif


Sincerley,
Zvi Gilboa



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-03-18  4:38 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 16:18 question: hard-coded file descriptors in stdin/stdout/stderr Zvi Gilboa
2013-03-14 17:17 ` Szabolcs Nagy
2013-03-14 17:51   ` Zvi Gilboa
2013-03-14 18:17     ` Szabolcs Nagy
2013-03-14 19:34       ` Zvi Gilboa
     [not found]     ` <CAFipMOE4xkYBYb1rEDtB0T8+Nfgs9cEG_=Va1=PKN4H6CLDHMw@mail.gmail.com>
2013-03-14 19:57       ` Zvi Gilboa
2013-03-15  8:33     ` Rich Felker
2013-03-15 11:43       ` LM
2013-03-15 14:46       ` Zvi Gilboa
2013-03-15 18:43         ` Rich Felker
2013-03-15 18:55           ` Zvi Gilboa
2013-03-15 19:03             ` Rich Felker
2013-03-15 19:20               ` Zvi Gilboa
2013-03-18  3:14     ` Rob Landley
2013-03-18  3:26       ` Rich Felker
2013-03-18  3:50         ` Strake
2013-03-18  4:08           ` Rich Felker
2013-03-18  4:30             ` Rob Landley
2013-03-18  4:09         ` Rob Landley
2013-03-18  3:28       ` Zvi Gilboa
2013-03-18  4:22         ` Rob Landley
2013-03-18  4:38           ` Zvi Gilboa
2013-03-18  3:06 ` Rob Landley

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).