Public Domain version of: yes(1)

Daniel R. Levy levy at ttrdc.UUCP
Thu Apr 14 12:19:47 AEST 1988


In article <2606 at bsu-cs.UUCP>, dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
> 
>      rm < /dev/yes
> 
> Pipes are well-known to be inefficient, and it makes no sense to create
> a new yes process when /dev/yes would be so much faster.

PIPES!  Why didn't I think of that before.  It's easy to kludge a "/dev/yes"
capability on systems that support named pipes; just put something like this
in the system startup script:

if [ ! -p /dev/yes ]; then /etc/mknod /dev/yes p; fi	# create a FIFO
chown root /dev/yes
chmod 644 /dev/yes
sh -c 'while :; do while :; do echo y; done >/dev/yes; done' &

Since the process is already running, and echo and ':' are shell builtins,
there is little overhead.  The nested loop is required since the inner
loop dies with EPIPE (broken pipe) whenever a process reading from /dev/yes
is killed, dies, or closes its file descriptor open onto the pipe.
-- 
|------------Dan Levy------------|  Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
|         an Engihacker @        |  	<most AT&T machines>}!ttrdc!ttrda!levy
|     AT&T Data Systems Group    |  Disclaimer?  Huh?  What disclaimer???
|--------Skokie, Illinois--------|



More information about the Alt.sources mailing list