LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux command execution flow (https://www.linuxquestions.org/questions/linux-newbie-8/linux-command-execution-flow-4175411203/)

hari_sahaya 06-13-2012 07:24 AM

Linux command execution flow
 
I wanted to know the flow of operations that takes place when a command is executed on shell. I guess that shell does a fork-exec. I need a little more elaboration.

Thanks!

MensaWater 06-13-2012 07:31 AM

For the most part commands are forked from the shell. You can even start a new shell which is forked from the original. When the command completes or exits it returns to the original shell.

You can use "exec <command>" to exec a command rather than fork it. However since the exec tells the command to replace the original process (the shell) it means once the command completes it will exit the system. This is sometimes desirable if say you've created a login specifically for the purpose of launching a command and don't want users to access the shell directly. (In such a case you also have to disable traps to insure the user can't hit ctrl-c or some other break/exit keystroke combination fast enough to get to shell prompt before the exec runs.)

hari_sahaya 06-14-2012 07:04 AM

Thank you!


All times are GMT -5. The time now is 03:49 PM.