When a shell (e.g. bash
) invokes an executable file, it first fork
itself, and then its copy execve
the executable file.
When a shell invokes builtin commands, there is no new process created, and execve
can only operate on executable files while builtin commands are not stored in executable files.
So how are builtin commands stored, and how are they invoked in terms of system calls?
"builtin command" means that you don't have to run an external program. So, no, there's no execve
involved at all, and no, there's not even any system call necessarily involved. Your shell really just parses a command string and sees "hey, that's a builtin command, let's execute this and that function".
You can imagine they are the same as shell functions.
So instead of launching external process the shell invokes some internal function library function which reads the input outputs the result and does pretty much the same as main function of regular program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With