Holdon is a UNIX command line filter.

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
GPL (GNU General Public License) 
Richard Whitty
ROOT \ Utilities
Holdon is a UNIX command line filter. It caches stdin until EOF, then writes it to a file passed on the command line.

It came about as I was working on bbots. In bash, you can't redirect to a file that is being read from earlier in the pipeline. This is because the file is opened with O_TRUC as soon as all the programs are started (remember, they all run at the same time). As a result, I kept having to do things like:

grep -v ${SOMEITEM} ${SOMELIST} > temp-file
mv temp-file ${SOMELIST}

Which began to really annoy me. obviously I've abstracted the list interaction away now, but that's not the only example.
To perform the above example with holdon, you'd do:

$ grep -v ${SOMEITEM} ${SOMELIST} | holdon ${SOMELIST}

which I think looks a lot cleaner. One other thing, I've hardcoded the buffer size to 4096 (the page size on x86) if you've got another architecture, change it.

This is only because the SSIZE_MAX #define mentioned in the read() spec. doesn't seem to exist on my system. Nor does O_DIRECT which is just odd. I've left these defines at the top of the file so you can change them if you want.

Actually, thinking about it now... maybe the page size isn't the best allocation unit to use... What about the meta-info from the memory allocator, however I don't think it would be right to try and tune for this, as it would only cost on the first allocation (as a whole page would be dedicated to the buffer?) -- meh.

Last updated on March 5th, 2007

#line filter #cache stdin #wait a minute #holdon #line #filter #cache

Add your review!