[singh@00-13-02-56-15-7c programs]$ vi zombie.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void main()
{
int id;
id=fork();
if(id>0)
{
printf("\nParent will sleep");
sleep(50);
execlp("ps","ps",(char *)0);
}
if(id==0)
{
printf("I am child\n");
exit(10);
}
}
Output :
[singh@00-13-02-56-15-7c programs]$ gcc zombie.c
[singh@00-13-02-56-15-7c programs]$ ./a.out
I am child
PID TTY TIME CMD
8845 pts/0 00:00:00 bash
9025 pts/0 00:00:00 ps
9026 pts/0 00:00:00 a.out
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void main()
{
int id;
id=fork();
if(id>0)
{
printf("\nParent will sleep");
sleep(50);
execlp("ps","ps",(char *)0);
}
if(id==0)
{
printf("I am child\n");
exit(10);
}
}
Output :
[singh@00-13-02-56-15-7c programs]$ gcc zombie.c
[singh@00-13-02-56-15-7c programs]$ ./a.out
I am child
PID TTY TIME CMD
8845 pts/0 00:00:00 bash
9025 pts/0 00:00:00 ps
9026 pts/0 00:00:00 a.out
No comments:
Post a Comment