is it possible to find which commnands make shell to Span a child process?
if so what is the determining criteria??
thanks
is it possible to find which commnands make shell to Span a child process?
if so what is the determining criteria??
thanks
This is a little more complicated than a post can deal with very well.
Let's use the Korn shell -- /bin/ksh as an example.
When you have in your script:
echo "hi there"
The "echo" is a command. Most commands invoke external programs. When a command runs as a program it creates a separate process - "spawn".
Not all commands are separate processes. The type command in ksh will tell you what the command is - whehter it is a shell builtin, an external program, etc.
vcspnm:/home/jmcnama> type echo
echo is a shell builtin
vcspnm:/home/jmcnama> type ls
ls is a tracked alias for /usr/bin/ls
vcspnm:/home/jmcnama> type while
while is a keyword
vcspnm:/home/jmcnama> type lp
lp is /usr/bin/lp
So: lp and ls are programs, while and echo are part of the shell.
If type tells you it is a builtin then no separate process is created. Same for a keyword like while or if.
The flip side of this is that you can force the shell to make a separate process:
echo "stuff " > somefile &
wait
This forces command to run in a separate process, even if it would normally not do so.
thank you man
you mean commnads are programs which will be "excecuted" upon invoking them
so these programs must be the "Source code" which will be compiled and executed just like any other user progrmas when the commnad is invoked.
if I am wrong I seek your advice.
No. ls is a command - it points to an already compiled ready-to-run program /usr/bin/ls In order to run the ls program the shell creates a separate process.
Not all commands are separate programs. The type command tells you what flavor each command is - knowing that you then know if the command will make a separate process or not.
I got it Man thanks for your time.