[rhn-users] Newbie Question - What is actually executing the binary?

Les Bell lesbell at lesbell.com.au
Sun Jun 6 02:02:44 UTC 2004


snodx at hotmail.com wrote:

>>
Here is the question, any thing that I type on Redhat's command terminal,
where is the command terminal actually sending it to? For eg if I
type say "ls -l" what is actually executing the "ls" binary in the
back-end?
<<

The commands you type are being interpreted by the bash shell. When you
press Enter, it will parse the command line, and will execute the ls as a
child process of the bash shell process. It does this by a rather curious
process called a 'fork-and-exec': the bash shell makes a fork() system call
which duplicates the bash process. Briefly, there are two bash processes -
the parent now waits for the child to run to completion, and the child now
makes an exec() system call, which replaces the code of the bash process
with the code of the ls program. Now the ls command runs and produces
output, and when it's done, it exits and the parent bash process resumes
execution by displaying the PS1 prompt again.

You should play around with the ps aux command and the pstree command to
investigate this. To help you figure it out, PID stands for Process ID and
PPID stands for Parent Process ID. All the processes are in a parent/child
hierarchy which starts with init - that's PID 1.

Best,

--- Les Bell, RHCE, CISSP
[http://www.lesbell.com.au]






More information about the rhn-users mailing list