Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • In x | y, why is there a sub-shell created? For my understanding, when bash sees a pipe, it executes pipe() system call, that returns two fds. Now, command_left is execed and the output is fed to command_right as input. Now, command_right is execed. So, why is BASHPID different each time? Commented Sep 3, 2013 at 5:21
  • 2
    @shadyabhi It's simple - x and y are 2 separate commands running in 2 separate processes, so you have 2 separate subshells. If x runs in the same process as the shell, that means x must be a built-in. Commented Sep 3, 2013 at 20:59