Introduction to Unix and OS
Module 2 Continued……
Dr. Girisha G S
Dept. of CSE
SoE,DSU, Bengaluru
Agenda
• Process Basics
• ps command
• Mechanism of process creation
• Internal and External Command
• Process States and Zombies
The Shell Process
• A shell is simply a process
• Every time you issue a command, the UNIX operating
system starts a new process and suspends the current
process (the shell) until the new process completes.
Example: $ cat emp.lst
Parents and Childerns
ps - Process Status
ps command options
fork()
Syntax:
#include <unistd.h>
pid_t fork(void);
execlp()
Syntax:
#include <unistd.h>
int execlp(const char *file, const char *arg, …,
NULL );
wait()
Syntax:
#include <sys/types.h>
#include <sys/wait.h>
pid_t wait(int * status);
Unix-  the process
Unix-  the process

Unix- the process

Editor's Notes

  • #7 This data is useful for such administrative tasks as determining how to set process priorities. Depending on which options you use, the ps command reports the following information:
  • #8 fork(): f fork() returns a negative value, the creation of a child process was unsuccessful. fork() returns a zero to the newly created child process. fork() returns a positive value, the process ID of the child process, to the parent. int execlp(const char *path, const char *arg0, ..., NULL); pathidentifies the location of the new process . arg0, ..., NULLis a variable length list of arguments that are passed to the new process image. Each argument is specified as a null-terminated string, and the list must end with a NULL pointer.  Wait() The return value from wait is the PID of the child process which terminated. The parameter to wait() is a pointer to a location which will receive the child's exit status value when it terminates