Re: what happens when i run ps command on shell prompt?

From: Philippe Amarenco (philippe_at_lse.epita.fr)
Date: 08/29/05


Date: Mon, 29 Aug 2005 23:01:56 +0200

rahul8143@gmail.com writes:

> hello,
> I want to know what exactly happens when i type $ps -a on shell
> prompt? Does it actually forks current environment and swithes to ps
> command code? Executes and retuen to parent process that is shell
> prompt?
> regards,
> rahul.
>

when executing a command from the shell, it forks, then close/open
file descriptors for redirections and such, then it execve to the
given command so that the forked shell is replaced by the
command. the original shell calls waitpid to wait that the process
running the command finish execution, then it continues.

-- 
Philippe Amarenco, aka Phix
epita 2007 - LSE - EpX
"if new true friend not protected for explicit private union, break
case and try using this." -- Nathan Myers, longest c++ sentence.


Relevant Pages

  • Re: Mikes linux projects list, introducing "mcsh"!
    ... > The ability to run a command in the parent process AFTER the child ... > Think of a batch program in Windows that changes the directory of the ... A shell script can do the same. ... > mcsh will have only ONE command for newbies to remember, ...
    (comp.os.linux.misc)
  • Re: CLOSING Re: Obtaining complete Unix command line that evoked script as string
    ... >>command-line used to launch a program regardless of the complexity that ... Only shell that launched them is keeping track of the I/O ... parent process and passing STDOUT back to the parent process. ... command is executed. ...
    (perl.beginners)
  • Bash-4.0 available for FTP
    ... Unlike previous bash distributions, this tar file includes the formatted ... The shell has been changed to be more ... rigorous about parsing commands inside command substitutions, ... Changes have been made to the Readline library being released at ...
    (gnu.announce)
  • Why newbies dont RTFM...
    ... Even though I've used Linux before, I've never had to do any ... BASH BUILTIN COMMANDS ... last command exited within ... unless the shell is not exeâ ...
    (comp.os.linux.misc)
  • Re: Great SWT Program
    ... None of the nasty things that you have said or implied about me are at ... treat the file as input (manually invoking the command interpreter ... script, copy the line into that within the editor, exit, and invoke ... the shell script. ...
    (comp.lang.java.programmer)