Answer the question
In order to leave comments, you need to log in
"cd | ls -R /" Does the shell create two processes with fork or just one for ls?
Actually, I can’t understand this ...
Here I was looking for a mention of how built-in should be called according to the standard, but I did not find it.
The question arose after jobs showed that cd had a pid:
[1] - 50095 done echo |
50096 suspended ls -R /
[2] + 50659 done cd |
50660 suspended ls -R /
Answer the question
In order to leave comments, you need to log in
It's so easy to find out, see:
$ strace -f -e clone,write,chdir bash -c "cd | echo 'zz'"
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1c61235a10) = 7494
strace: Process 7494 attached
[pid 7493] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1c61235a10) = 7495
strace: Process 7495 attached
[pid 7494] chdir("/home/jcmvbkbc") = 0
[pid 7495] write(1, "zz\n", 3zz
) = 3
[pid 7494] +++ exited with 0 +++
[pid 7495] +++ exited with 0 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7494, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
+++ exited with 0 +++
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question