From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2931 Path: news.gmane.org!not-for-mail From: Rob Landley Newsgroups: gmane.linux.lib.musl.general Subject: Re: question: hard-coded file descriptors in stdin/stdout/stderr Date: Sun, 17 Mar 2013 22:06:10 -0500 Message-ID: <1363575970.15703.20@driftwood> References: <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=us-ascii; DelSp=Yes; Format=Flowed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1363575989 989 80.91.229.3 (18 Mar 2013 03:06:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Mar 2013 03:06:29 +0000 (UTC) Cc: musl@lists.openwall.com To: musl@lists.openwall.com Original-X-From: musl-return-2932-gllmg-musl=m.gmane.org@lists.openwall.com Mon Mar 18 04:06:53 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 1UHQPT-0001w6-1c for gllmg-musl@plane.gmane.org; Mon, 18 Mar 2013 04:06:51 +0100 Original-Received: (qmail 11521 invoked by uid 550); 18 Mar 2013 03:06:26 -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 11513 invoked from network); 18 Mar 2013 03:06:26 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:from:subject:to:cc:in-reply-to:x-mailer:message-id :mime-version:content-type:content-disposition :content-transfer-encoding:x-gm-message-state; bh=kq3GFUgKdYlF6PfMhrZeDQssXlie88VBedXijQhzkwU=; b=E5E/MrMUH3NKnbdE/TEIAmh87S+smeoW2/Uy+9t8uW4UlZ9Te6DrPgfHRxPNmFncQB rbKsj5AGqO3+xRQoe25WfFX9cQ40+3ds5BApd+HBtvnBpG6vD4BMD06Jq8b2Kh8pJt1m guE6KXelggyOb3b/ZRDVhjsUWBvqfVRmTap0MbfdEdyEYDk7wma46hbWgOlg5xIkRNQq qgsv9AgEClP2qmu+F+0BuqcyC4Wpd6ZJh6K61obYJWZVeumw6LtkpxhoPClzyGOurQze +m3trD3x1J/BPQkfmxmCM0HfkS27lr3pTYwxieWrJxOXJ6gaYQBnt+jSnpryxdftZaJG nnig== X-Received: by 10.50.73.65 with SMTP id j1mr5559168igv.49.1363575973865; Sun, 17 Mar 2013 20:06:13 -0700 (PDT) In-Reply-To: <5141F86D.8010000@eservices.virginia.edu> (from zg7s@eservices.virginia.edu on Thu Mar 14 11:18:53 2013) X-Mailer: Balsa 2.4.11 Content-Disposition: inline X-Gm-Message-State: ALoCoQmnrIudGoWMh+WHnVMoDr1m7blTCaZmspdMGQgIFLDsTB9wMMEJEj5TfwStL0Ao55kmCeI7 Xref: news.gmane.org gmane.linux.lib.musl.general:2931 Archived-At: On 03/14/2013 11:18:53 AM, Zvi Gilboa wrote: > Greetings, >=20 > I just noticed that the file descriptors in stdin.c, stdout.c, and =20 > stderr.c do not use the #defines from (namely =20 > STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO), but are rather =20 > hard-coded (as 0, 1, and 2 respectively). Because these have been constant values since 1969, were adopted by DOS =20 in 1983, and the numerical values are SPECIFIED BY POSIX: http://pubs.opengroup.org/onlinepubs/9699919799/functions/stdin.html STDIN_FILENO - Standard input value, stdin. Its value is 0. STDOUT_FILENO - Standard output value, stdout. Its value is 1. STDERR_FILENO - Standard error value, stderr. Its value is 2. > I was therefore wondering whether there was a special reason for that? Because MUSL is simple and using a macro to specify a constant that's =20 standardized by posix, has been stable for over 40 years, and is =20 regularly used on the command line, is pointless? > With POSIX systems this would normally not be an issue, however there =20 > are still some > systems out there with standard file descriptor numbers which are =20 > different... Posix specifies the value of the constant. Supporting systems that =20 violate posix was not, last I checked, part of musl's goals? > On that same note: wouldn't it make sense to slightly modify unistd.h =20 > so that it > first checks whether STDIN_FILENO, etc. have already been defined? =20 > That would allow > a system with different standard file descriptor numbers to define =20 > them in one of > the /arch headers, yet enable the default for systems that use the =20 > "normal" numbers. > The relevant section would then read: What system are you referring to? "There are systems" means what, =20 exactly> Not Linux, not Mac, not Android, not iOS... what are you referring to? Rob=