AOS Lect 08 Process
AOS Lect 08 Process
(CS G623)
LECTURE 8: PROCESS
30 August 2014
30 August 2014
< -1 which means to wait for any child process whose process
group ID is equal to the absolute value of pid.
-1 which means to wait for any child process; this is the
same behavior which wait exhibits.
0 which means to wait for any child process whose process
group ID is equal to that of the calling process.
> 0 which means to wait for the child whose process ID is
equal to the value of pid.
30 August 2014
WNOHANG
return immediately if no child has exited
WUNTRACED
return for children which are stopped, and whose status has
not been reported
WCONTINUED
Returns if a stopped child has been resumed by delivery of
SIGCONT
30 August 2014
else if (pid == 0) {
printf( This is from child
process I am exiting\n);
exit(2);
}
else {
printf(This is from parent
process\n);
}
wait(&status);
// waitpid(pid, &status,0);
// Child is no more and this part is
only for Parent
printf(Child exited already now
with exit status %d\n,status);
return 0;
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
pid_t pid;
int status;
printf(fork program starting \n);
pid = fork();
if (pid < 0 ){
perror(fork failed\n);
exit(1);
}
}
30 August 2014
exec() family
30 August 2014
30 August 2014
30 August 2014
#include <stdio.h>
#include <unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main(){ pid_t pid;
int status;
const char *ps_argv[] =
{ps, -ax, 0};
const char *ps_envp[] =
{PATH=/bin:/usr/bin,
TERM=console,0};
printf(fork program starting \n);
pid = fork();
if (pid < 0 ){
printf(fork failed\n);
exit(1);
}
30 August 2014
10
Clock interrupt
I/O interrupt
Memory fault
Trap
Supervisor call
30 August 2014
11
Context Switch
30 August 2014
12
30 August 2014
13
30 August 2014
14
Process termination
Normal completion
Time limit expired
Errors
Failures
Operator/OS intervention
Parent terminated
Parent request
30 August 2014
15