Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
    
Thank you, it is clear now :) – Steven Dec 16 '14 at 21:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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