From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Mon, 31 Oct 2011 18:24:13 -0400 To: rminnich@gmail.com, 9fans@9fans.net Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] native (mostly) go for plan9 Topicbox-Message-UUID: 3d3548f6-ead7-11e9-9d60-3106f5b1d025 > OK, now, the current problem with syscall/exec_plan9.go is that it is > a little too eager to close FDs. It's doing the close by hand because > it's not possible on Plan 9 to take an fd and set to to close-on-exec > -- that's only done on open on Plan 9 (on unix the code does an > fcntl). But if an FD is used twice for a child -- as it is with > combined stdout/stderr -- then the close closes the fd before it can > be dup'ed a second time. Bad. > > I did the lazy thing and commented out the erroneous close for now. > The easy fix is to track the fds to be closed in a map and then close > them all later. That's next. Another possibility is to allow '#d/*ctl' > to be writeable and implement a > closeonexec > control message for fds. But maybe that's just too much. It is > certainly easy to do, but is that kind of feature something we want to > add? just a silly idea, perhaps dup takes an additional argument int dup(int old, int new, int flags); if old and new are the same, flags are applied as if they were given on open. e.g. dupf(fd, fd, OCEXEC); (by the way, i would put in a word for OCFORK.) - erik