From: Ville Herva <vherva@niksula.hut.fi>
To: Riley Williams <rhw@MemAlpha.cx>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: Need blocking /dev/null
Date: Thu, 1 Nov 2001 09:24:07 +0200 [thread overview]
Message-ID: <20011101092407.H1504@niksula.cs.hut.fi> (raw)
In-Reply-To: <20011031112303.A26218@niksula.cs.hut.fi> <Pine.LNX.4.21.0110312256030.28028-100000@Consulate.UFP.CX>
In-Reply-To: <Pine.LNX.4.21.0110312256030.28028-100000@Consulate.UFP.CX>; from rhw@MemAlpha.cx on Wed, Oct 31, 2001 at 11:13:22PM +0000
On Wed, Oct 31, 2001 at 11:13:22PM +0000, you [Riley Williams] claimed:
> Hi Ville.
>
>
> > Certainly have in the sense that you could theoretically do that in
> > user space.
>
> Are you sure?
In theory, yes.
> > find / -name "wanted-but-lost-download" | eat
>
> Doesn't work - you're piping the stdin there, not stderr as per my
> example above.
Sorry, I wasn't careful enough.
> AFAIK, there's no way to pipe stderr without also piping
> stdout, hence this sort of solution just doesn't work.
One could argue that is a fault of the shell - which again is a userland
thing.
If anything else fails, you could do
% touch y; rm -f x
% ls x y
ls: x: No such file or directory
y
% mkfifo f
% ls x y 2> f & wc -c f
y
33 f
rm f
Which of course isn't pretty, but it's doable. Of course, I'm not arguing
that we should get rid of /dev/null and /dev/zero, but that in theory you
could implement them in userspace.
Come to think of it, the biggest gain from /dev/null and /dev/zero comes
propably when you do memmaps. I'm not actually sure whether you could all
tath without /dev/null and /dev/zero - or you could, but with performance
loss.
> AFAICS, there is no sane alternative to /dev/null in userspace.
Sane is relative...
> > zerofill | head -c 1440k > /tmp/floppy.img
>
> How does zerofill know when to stop writing zeros out? After all, if it
> doesn't write enough out for the head call, then it's no longer an
> equivalent to /dev/zero, and it could easily be called with just about
> ANY positive number of bytes, including an infinite number, as in...
>
> zerofill | tr '\0' '@' > /dev/ttyS1
>
> ...which sends an infinite stream of 0x40 bytes to the serial port.
Of course it writes infinitely. When head terminates the pipe, it exits.
Just try
yes | head -c 10
Or with any characters. It gets SIGPIPE when the other end closes the pipe.
> However...
>
> zerofill 750M > /tmp/img.cd
> zerofill 1440k > /tmp/img.floppy
>
> ...would be a reasonable userspace equivalent to examples (2) and (3)
> respectively, so that certainly could be done in userspace.
That's equivalent to
zerofill | head -c 750M > /tmp/img.cd
Unless I missed something.
-- v --
v@iki.fi
next prev parent reply other threads:[~2001-11-01 7:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-29 21:07 Marko Rauhamaa
2001-10-29 21:24 ` Alan Cox
2001-10-30 3:52 ` Marko Rauhamaa
2001-10-30 7:02 ` Tim Connors
2001-10-30 16:04 ` Marko Rauhamaa
2001-10-31 0:51 ` Riley Williams
2001-10-31 9:23 ` Ville Herva
2001-10-31 23:13 ` Riley Williams
2001-11-01 0:11 ` Doug McNaught
2001-11-01 7:27 ` Ville Herva
2001-11-01 7:52 ` Abramo Bagnara
2001-11-01 23:51 ` Riley Williams
2001-11-02 19:53 ` Ville Herva
2001-11-02 20:04 ` John Adams
2001-11-02 20:32 ` Ville Herva
2001-11-02 20:46 ` Tim Walberg
2001-11-05 22:08 ` Andreas Schwab
2001-11-01 7:24 ` Ville Herva [this message]
2001-10-29 21:45 ` Hugh Dickins
2001-10-29 23:03 ` elko
2001-10-29 23:12 ` Mike Fedyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20011101092407.H1504@niksula.cs.hut.fi \
--to=vherva@niksula.hut.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=rhw@MemAlpha.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®