From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2918 Path: news.gmane.org!not-for-mail From: LM Newsgroups: gmane.linux.lib.musl.general Subject: Re: question: hard-coded file descriptors in stdin/stdout/stderr Date: Fri, 15 Mar 2013 07:43:03 -0400 Message-ID: References: <5141F86D.8010000@eservices.virginia.edu> <20130314171752.GB19010@port70.net> <51420E17.9030305@eservices.virginia.edu> <20130315083357.GH20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1363347793 29579 80.91.229.3 (15 Mar 2013 11:43:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Mar 2013 11:43:13 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2919-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 15 12:43:39 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 1UGT2w-0007TQ-Ia for gllmg-musl@plane.gmane.org; Fri, 15 Mar 2013 12:43:38 +0100 Original-Received: (qmail 19612 invoked by uid 550); 15 Mar 2013 11:43:14 -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 19604 invoked from network); 15 Mar 2013 11:43:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=TbfRiRRvX4+l3HIv8gqZsxHy/ZA45KBHsqx78UMdcLs=; b=kd6vy6wndQuxel4XNa9DFkVFa1xN37OP0esdvPfH6QENfDUOQnPmVonasNpo/cn0xb 79EMBLrosFz6Z/hTUqn7BYdwyGh9iRm7+h5kwzuJDY5lwlCvwevgqUA/cAAF8NS/xDFF bwGUv1eHv7Hu2FPyU9RQiSBT+YzPxcDQCso20a0SqWahDsCf9EBWB6bMSRfQITnvxI6N JvCboXiHbvW3eryTXyv7oJUqV9mcQoXYTZnzDzn/M1zX9IuXqgcXQrE0c77xDup3GjYf YU1rWUkTf5s+PzbmHVYovnAc+o9gCvx8wDr8Bvtt3zsCLRuURueQC3Yn61NAQwHW2UaN GWLg== X-Received: by 10.15.100.202 with SMTP id bn50mr17198048eeb.36.1363347783276; Fri, 15 Mar 2013 04:43:03 -0700 (PDT) In-Reply-To: <20130315083357.GH20323@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:2918 Archived-At: On Fri, Mar 15, 2013 at 4:33 AM, Rich Felker wrote: > Not only are > the numbers 0/1/2 specified and widely hard-coded in applications; the > Windows "file handle" values for stdin/out/err are not usable as file > descriptors because they are negative. Was just thinking about that this morning. I've been trying to port msh to Windows and it uses hard-coded 0, 1 and 2 with pipes and expects them to mean stdin, stdout and stderr. I'm guessing MinGW does something in its code to deal with the situation, because it works with these hard-coded numbers when I build msh. Would be nice if it worked the same way with a replacement library such as musl if used on Windows. > Nice to hear. Incidentally, fork() was one of the interfaces I thought > we could just sacrifice in doing such a libc (posix_spawn or the > similar Windows function can replace most correct uses of fork()), so > it's nice to hear you've solved the problem. That's pretty much what I do when I port applications to Windows; I substitute spawn. Seems easier to replace vfork than fork that way though. One other issue I hit when porting to Windows is the lack of certain signal handling capabilities. For instance, when attempting to port flrec, in place of kill(pid_sox,SIGSTOP);, I'm trying to use NtSuspendProcess and in place of SIGCONT, I'm trying to use NtResumeProcess. Some of the other signal information used in the program, I'm not even sure if I can duplicate on Windows yet. Would be nice if musl does get ported to Windows. It could do a lot towards simplifying porting of other applications.