From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2911 Path: news.gmane.org!not-for-mail From: Zvi Gilboa Newsgroups: gmane.linux.lib.musl.general Subject: question: hard-coded file descriptors in stdin/stdout/stderr Date: Thu, 14 Mar 2013 12:18:53 -0400 Message-ID: <5141F86D.8010000@eservices.virginia.edu> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1363277958 7759 80.91.229.3 (14 Mar 2013 16:19:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Mar 2013 16:19:18 +0000 (UTC) To: Original-X-From: musl-return-2912-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 14 17:19:44 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UGAsY-0003vI-CX for gllmg-musl@plane.gmane.org; Thu, 14 Mar 2013 17:19:42 +0100 Original-Received: (qmail 22130 invoked by uid 550); 14 Mar 2013 16:19:19 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 22117 invoked from network); 14 Mar 2013 16:19:19 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 X-Originating-IP: [68.229.98.213] Xref: news.gmane.org gmane.linux.lib.musl.general:2911 Archived-At: Greetings, I just noticed that the file descriptors in stdin.c, stdout.c, and stderr.c do not use the #defines from (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