I have some problems when trying to run an interactive sh session inside a shell script. The inner sh process uses all the CPU and never terminates.

To reproduce the issue simply create a file named "script.sh" containing something like this:

sleep 10 | sh -i | sleep 10 &

and execute it using:

sh script.sh

sleep commands are just placeholders, I have other commands piping input into sh -i and processing its output. I know this is a very odd setup but it would be better if I could use an interactive shell and, at this point, I'm very curious and I want to understand what's happening.

1 Answer 1


You inner shell is not interactive; remove the -i flag and it should stop freaking out.

See What should interactive shells do in orphaned process groups? for an explanation of what is going on under the cover.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .