There are many solutions, but they also have some shortcomings:
sleep infinity
is a top choice, but it is not supported by some libc/musl versions.sleep 100000d
is good, but will eventually terminatetail -f /dev/null
wakes up each time some process drops something to /dev/null, and uses inotify resourcesecho 'void main(){ pause(); }' > pause.c; gcc pause.c -o pause; ./pause
requiresgcc
to be installed- piping from a halted shell with
sh -c 'kill -STOP $$' | program > output
will keep going even after the program is terminated
A good alternative that avoids these limitations is waiting on a halted process:
while :; do :; done & kill -STOP $! && wait $!
The single ampersand &
will put the while loop in the background. The kill
will halt it using it’s process id. wait
will wait on it indefinitely.