Commands are essentially user space applications that mostly use system library (libc) to talk to kernel. Libc has system call wrappers to talk to kernel.
Here are the things that happens when you type a command and hit enter :
1> Shell checks if the command issues is a builtin. Builtins are commands that shell provides and are implemented within the shell code itself. For example, cd is a shell builtin. It just executes chdir() to $HOME within shell code.
2> If the command issued is not a shell builtin, it is searched in the standard paths as speciefied by $PATH. If it is found, shell creates a new child using fork(), and execs the command in the child using execve() system call. Shell waits for all the children it has forked. Shell also manages the terminal association for the fore ground process.
3> If the command is not found in the path and no relative or full path is specified when the command was issued, then shell will return an error.
SOURCE : QUORA
Here are the things that happens when you type a command and hit enter :
1> Shell checks if the command issues is a builtin. Builtins are commands that shell provides and are implemented within the shell code itself. For example, cd is a shell builtin. It just executes chdir() to $HOME within shell code.
2> If the command issued is not a shell builtin, it is searched in the standard paths as speciefied by $PATH. If it is found, shell creates a new child using fork(), and execs the command in the child using execve() system call. Shell waits for all the children it has forked. Shell also manages the terminal association for the fore ground process.
3> If the command is not found in the path and no relative or full path is specified when the command was issued, then shell will return an error.
SOURCE : QUORA
No comments:
Post a Comment