Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If you fork (exec) two interactive bash processes within same parent process (from different threads) causes that parent process becomes stopped or second interactive bash goes to background which further causes that second bash consumes 100% CPU because of conflicts of interactive and background attributes.

This is happening in Linux but not in Cygwin.

Example:

In same Java process (same thing is happening in other programming language):

Thread 1

Process process1;
String[] command1 = new String[] { "bash", "-l", "-c", "bash -i -l  2>&1" };
process1 = Runtime.getRuntime().exec(command1);

Thread 2

Process process2;
String[] command2 = new String[] { "bash", "-l", "-c", "bash -i -l  2>&1" };
process2 = Runtime.getRuntime().exec(command2);

What is causing such behavior?

If above example is executed in two separate processes there are no problems. So, it seems related to fact that those bash processes have same root parent process (and maybe confusing tty and control signals).

Thanks for help.

share|improve this question

migrated from serverfault.com Feb 18 at 21:52

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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