Date: Tue, 18 Dec 2001 19:56:15 -0500 From: Sergey Babkin <babkin@bellatlantic.net> To: Erik Trulsson <ertr1013@student.uu.se> Cc: Steve Price <steve@FreeBSD.org>, Andreas Klemm <andreas@FreeBSD.org>, 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 Message-ID: <3C1FE5AF.5E93ED0D@bellatlantic.net> References: <200112171847.fBHIlbP69769@freefall.freebsd.org> <20011217130555.J72144@bsd.havk.org> <20011217201850.A21347@student.uu.se>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C1FE5AF.5E93ED0D>