-   Linux - Newbie (
-   -   Linux command execution flow (

hari_sahaya 06-13-2012 08: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.


MensaWater 06-13-2012 08: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 08:04 AM

Thank you!

All times are GMT -5. The time now is 02:52 PM.