3

I have a program which manages processes. It is designed for managing long-running processes, and when one of its processes exits, even successfully, then the whole process manager closes.

For example, I have this config file for the process manager:

foo: foo --do-foo
bar: bar --do-bar

The "foo" command might exit 0, causing the whole process manager (and thus also the command bar --do-bar) to close.

Avoiding submitting a change to said process manager, or using a different one, I'm thinking I can fool it into not exiting by adding another "innocuous" command to the end of my command which will cause it to "stall," and thus the process manager will not close. Some ideas that come to mind are calling && ruby or && read to make the command stall.

So, returning to my previous example, I would change my config file to:

foo: foo --do-foo && read
bar: bar --do-bar

Then, even if foo --do-foo exited 0, the command would "stall" because I called read, and then the process manager would not close.

Are either ruby or read "innocuous" and/or "cheap" commands to run to trick my process manager? Or is there an even simpler command that I could run to make the process "stall" and consume very few / none system resources?

  • I'm not aware of any Unix ever with a read program; there is a read builtin command in shell but those aren't directly accessible to an external program like your manager. You could do $SHELL -c read iff stdin is something that does not return either data or EOF. OTOH as you answered sleep is even better. – dave_thompson_085 Jun 20 '17 at 5:25
6

sleep infinity is probably what I was looking for.

  • Does not work on macOS but sleep 9999999 does, as well as while true; do sleep 10000; done. – Akseli Palén Oct 6 '18 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.