🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1148

Re: pipe equivalent to /dev/null ???

#1148
From: Chris Torek
Date: Sun, 16 Sep 1990 16:09
30 lines
1902 bytes
In article <13731@ulysses.att.com> cjc@ulysses.att.com (Chris Calabrese)
writes:
>I've been following this thread for some time, and I have
>to say that neither '... | true' nor '... | :' will do the trick.
>I thought this would be obvious.

This much is correct, but:

>'true' and ':' don't read their stdin, thus the process feeding them
>would block and never run.

... several people have made this claim, and I cannot understand why.
Since this is going on in comp.unix.shell, and all the examples are
using shells, we can assume that the pipe is properly set up, i.e., the
process writing on it does not have it open for reading as well.  Since
`true' and `:' exit as soon as they are run, when the first process
first tries to write on the pipe it will get an error and a SIGPIPE
signal.

>A slightly better approach than '... | cat > /dev/null' is a trivial
>program which reads its input and creates no output.

Why is this better?  It saves one system call per pipe-read, but other
than that it takes more work and a separate program.  Writing to /dev/null
is very efficient (there are no user-to-kernel copies involved; indeed,
you can pass illegal addresses to write() if and only if you are writing
to /dev/null).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris
Technical Details
Message-ID: <26569@mimsy.umd.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uwm.edu!rpi!bu.edu!purdue!haven!mimsy!chris
References: <8720001@hpdmd48.boi.hp.com> <3841@se-sd.SanDiego.NCR.COM> <13731@ulysses.att.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uwm.edu!rpi!bu.edu!purdue!haven!mimsy!chris
From: chris@mimsy.umd.edu (Chris Torek)
Newsgroups: comp.unix.shell
Subject: Re: pipe equivalent to /dev/null ???
Keywords: true and : won't work
Message-ID: <26569@mimsy.umd.edu>
Date: 16 Sep 90 16:09:00 GMT
References: <8720001@hpdmd48.boi.hp.com> <3841@se-sd.SanDiego.NCR.COM> <13731@ulysses.att.com>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 30