From owner-cvs-all Tue Dec 18 16:56:45 2001 Delivered-To: cvs-all@freebsd.org Received: from out006pub.verizon.net (out006pub.verizon.net [206.46.170.106]) by hub.freebsd.org (Postfix) with ESMTP id 13C9F37B416; Tue, 18 Dec 2001 16:56:25 -0800 (PST) Received: from bellatlantic.net (pool-151-198-135-228.mad.east.verizon.net [151.198.135.228]) by out006pub.verizon.net with ESMTP ; id fBJ0uGE26939 Tue, 18 Dec 2001 18:56:16 -0600 (CST) Message-ID: <3C1FE5AF.5E93ED0D@bellatlantic.net> Date: Tue, 18 Dec 2001 19:56:15 -0500 From: Sergey Babkin Reply-To: babkin@freebsd.org X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 4.0-19990626-CURRENT i386) X-Accept-Language: en, ru MIME-Version: 1.0 To: Erik Trulsson Cc: Steve Price , Andreas Klemm , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: ports/print/apsfilter Makefile ports/print/apsfilter/files patch-bin::aps2file ports/print/apsfilter/scripts pre-configure References: <200112171847.fBHIlbP69769@freefall.freebsd.org> <20011217130555.J72144@bsd.havk.org> <20011217201850.A21347@student.uu.se> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Erik Trulsson wrote: > > On Mon, Dec 17, 2001 at 01:05:55PM -0600, Steve Price wrote: > > On Mon, Dec 17, 2001 at 10:47:37AM -0800, Andreas Klemm wrote: > > > Log: > > > Unluckily FreeBSD's shell isn't able to read from/write to /dev/stdin > > > and stdout. > > > > Perhaps I missed the discussion somewhere else but can you please > > explain what this means and give an example of a short script that > > doesn't work with /bin/sh? > > Just try the following command: > > echo "hello" > /dev/stdout > > If you use tcsh or zsh (or presumably bash but I haven't tried that) this > will indeed output "hello" to stdout. > If you use /bin/sh it will instead complain that it cannot create > /dev/stdout. > > This is probably a bug in /bin/sh It gives EBADF (and the same thing for >/dev/fd/1). Apparently sh does not have the descriptor 1 open at the time when it does the output redirection. As you can see from Bernd Walter's trace, 60779 sh CALL close(0x1) 60779 sh RET close 0 60779 sh CALL open(0x80ecf14,0x601,0x1b6) 60779 sh NAMI "/dev/stdout" 60779 sh RET open -1 errno 13 Permission denied it does somehitng like: /* first it does whatever it needs with the descriptor 0 */ close(1); open(newfile,...); /* this would open the new file at descriptor 1 */ But as you can see, when it does open(), the descriptor 1 is closed, so naturally the pseudo-device /dev/stdout fails. It can be changed to f = open(newfile,...); close(1); dup(f); close(f); to fix this problem. As a temporary workaround the following command has the same effect: echo "hello" 3>/dev/stdout >&3 -SB To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message