The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 05-26-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
A better way to think about it is that "subshell" is not guaranteed to be a new process. Look carefully at the definition of ( ) and you find "separate environment" rather than "new process". As long as no side effects propogate into the parent environment, it could be done without a fork and forking is expensive. So this leaves the door open for faster implementations. Also Dave Korn wanted ksh to be universal and some OS's do not allow fork(). (They may have a spawn() which is like a fork()/exec() combo or something like that.)

Anyway, I thought of a way to do it...I think. Background the subshell. Have the parent obtain $! and send it into the subshell via a named pipe. Then the parent waits for the subshell to exit.