/////////////////////////////////////////////////////////////////Zombie process///////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
void main(){
pid_t child_pid, parent_pid;
child_pid = fork();
if (child_pid<0){
printf("Fork Unsuccessful\n");
exit(0);
}
if (child_pid==0){
printf("[CHILD] My PID is: %d\n", getpid());
printf("[CHILD] My parent's PID is: %d\n", getppid());
printf("[CHILD] I am exitting...\n");
exit(0);
}
else{
printf("[PARENT] My PID is: %d\n", getpid());
printf("[PARENT] My child's PID is: %d\n", child_pid);
printf("[PARENT] I'm sleeping for 10 secs...\n");
sleep(10);
printf("[PARENT] My child (pid:%d) has terminated but its entry is in the process table. It's a zombie process\n", child_pid);
}
}
///////////////////////////////////////////////////////////////Orphan process/////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
void main(){
pid_t child_pid, parent_pid;
child_pid=fork();
if (child_pid<0){
printf("Fork Unsucessful\n");
exit(0);
}
if (child_pid==0){
printf("[CHILD] My PID is %d\n", getpid());
printf("[CHILD] My parent's PID is %d\n", getppid());
printf("[CHILD] I am sleeping for 10 secs...\n");
sleep(10);
printf("[CHILD] My Parent Process has terminated. I am an orphan process adopted by Init Process(pid:%d)\n",getppid());
}
else{
printf("[PARENT] My PID is %d\n", getpid());
printf("[PARENT] My child's PID is %d\n", child_pid);
printf("[PARENT] I am exitting...\n");
exit(0);
}
}
i) Parent process should create a child process
ii) Both parent child processes should display their pid and parent’s pid; parent process should also its child’s pid
iii) Load a new program into child...
#!/bin/bash
echo "Enter three numbers (space seperated): "
read a b c
echo -n "Largest Number: "
if [ $a -ge $b -a $b -ge $c ]
then
echo "$a"
elif [ $b -ge $a -a $a -ge $c ]
then
echo "$b"
else
echo...