Linux Mastering Development

Whats is the difference between executing in subshells vs using & vs coproc command?

I was recently reading about subshells in linux. An example used was sleep 10.

(sleep 10)  -  subshell
sleep 10&   - background process
coproc sleep 10  

It was written that the first command executes in a subshell. The second is the background process without involving a subshell. And the third one was a combination of both.
I had tested using ps -ef and all of these commands show the creation of a subshell. Is there any difference between background process using & and and subshells? Also coproc seems to do the same thing. I am totally confused. Any light on the topic would be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *