...is a tiny Linux utility for running multiple programs in parallel, like a (very) stripped-down version of GNU parallel.
It has no dependencies aside from libc and produces tiny static build, making it suitable for use in containers or low-resource environments.
Install musl-gcc (on Ubuntu, you will need the gcc and musl-tools packages) and run ./build.sh.
This will produce a static binary in build/multirun.
Alternatively, compile multirun.c with a C compiler of your choice.
The command line for each subprocess is supplied in sequence, prefixed by a command separator of your choice:
./multirun [<command separator> <command>]*
For example:
./multirun -- /bin/echo 123 -- /bin/sleep 3 -- /bin/sh -c "sleep 2; echo Hello World!"The command separator should be a string that does not occur in the subprocess command lines. If you don't know what the subprocess command lines will be in advance, you can use a long random string:
./multirun 39c2b4f73caf3e74 $COMMAND_1 39c2b4f73caf3e74 $COMMAND_2 39c2b4f73caf3e74 $COMMAND_3multirun exits with exit code 0 if (and only if) all subprocesses exited with exit code 0.
By default, if a subprocess exits with a nonzero exit code, multirun still waits for all other subprocesses to finish before returning.
Setting the MULTIRUN_ON_FAILURE environment variable to ABORT changes this behavior - in that case, when a subprocess exits with a nonzero exit code, multirun sends a SIGTERM signal to all other subprocesses which are still running:
MULTIRUN_ON_FAILURE=ABORT ./multirun -- /bin/echo "Hello World!" -- /bin/sh -c "sleep 1; exit 1" -- /bin/sh -c "sleep 2; echo You should not see this!"Note that the SIGTERM is only sent to the direct children started by multirun.
If one of these children started children of its own, they will not receive a SIGTERM.
Copyright (c) 2025 Valentin Dimov
This project is licensed under the zero-clause BSD license, see LICENSE.