typicallyTypically you run this under bash. process working and starting concurentlyconcurrently, but are running by the shell pararellyin parallel. how itHow is it possible?
- if it isn't last command in pipe, create unnamed pipe with pair of sockets
- fork
- in child reassign stdin/stdout to sockets if it's needed (for first process in pipe stdin is not reassigned, the same for last process and his stdout)
- in child EXEC specified command with arguments that sweep out original shell code, but leaves all opened by them sockets. child process ID will not be changed because this is the same child process
- concurentlyconcurrently with child but pararellyparallel under main shell go to step 1.
system not quaranteeguarantee how fast exec will be executed and specified command starts. it's independedindependent to the shell, but system. thisThis is because:
ps auxww| grep ps | cat
once show grepgrep and/or psps command, and next now. itIt depends how fast kernel really start processes using system exec function.