This question is relevant to the question of 'what happens when we type a simple command on shell?' I posted earlier. (I thought it would be better to post it separately. But if not, please let me know.)
I learned from the previous question that the shell built-in commands are treated specially and normal external commands are executed on child process.
This time, I would like to trace system calls such as fork, clone, or execve to monitor what really happened after typing command. But I can only trace an execve call execve("bin/ls",,,) = 0
when I execute strace
like this way.
strace -etrace=execve,clone ls
That means, as I guess, I can only monitor system calls which are called after a child process is created.
To monitor all system calls related to creating new process, What I have to do? To invoke command with bash -c
like strace -etrace=execve,clone bash -c '{ ls; }'
would be helpful in this case?
-f
(or-ff
) option to strace for it the follow children.strace -f -etrace=execve,clone bash -c '{ ls; }'
should do what you are looking for.