split-exec - Fork the command for its split of input
split-exec [ options ] command ...
split-exec --help
split-exec --man
This program will fork a new child for each chunk of input.
The assumption is that the child will take a ``long time'' before it produces any output but that once it starts producing output, it will complete ``quickly''.
The potential performance gain comes from the ability to overlap this ``long time'', for example, input-output tasks like ``count the number of lines in all files in the given directory''.
Both the command and the environment are implicitly trusted and no checks are made to ensure they will not result in something undesired. For example, $PATH is propagated as-is.
To avoid the obvious deadlock, all the lines are read in and then child is executed.
Here are some contrived examples, mainly to demonstrate the syntax and how this is meant to work. Hopefully, you have real work to do and this script will be of some use to you.
perl -e 'print join "\n", 1..20, "\n";' | split-exec factor
perl -e 'print "dummy\n" x 20' | split-exec --children=5 -- perl -pe 'sleep rand 10'
perl -e 'print "dummy\n" x 20' | split-exec --timeout=5 -- perl -pe 'sleep rand 10'
This script will exit with zero upon successful completion, non-zero on any error. All debugging or diagnostic output is written to STDERR. Please do not ignore STDERR.
$Id: split-exec.html,v 1.3 2008/05/17 07:00:42 suter Exp $
Copyright (c) 2002 Mark Suter <suter@humbug.org.au>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.