Bumped into an unexpected bash/sh behavior and I wonder someone can explain the rationale behind it, and provide a solution to the question below. In an interactive bash shell session, I execute: $ bash -c ‘sleep 10 && echo’ With ps on Linux it looks like this: _ -bash _ bash -c sleep 10 && echo _ sleep 10 The
Tag: subshell
local variables in linux
When we export a local variable declared within a current shell does it get passed to future sub shells,processes , child processes or future child processes? I was told it get passed to future sub shells. Is it correct? Answer This simple test will answer you by itself: Breaking it down: No export … … leads to VAR1 not being
Why does shell command “{ command1; command2: } &” open a subshell?
As we all know, placing a list of commands between curly braces causes the list to be executed in the current shell context. No subshell is created. But when using “&” after “{}”, why two subshells are created? pid 1002 and 1003. when using “./a.out &”, only a subshell is created. pid 17358. Why ? Answer Background execution of a