Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- int main(void)
- {
- char pid[10];
- execlp("ls", "ls", (char*)NULL);
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- sleep(120);
- return 0;
- }
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- sleep(120);
- return 0;
- }
- sleep(120);
- return 0;
- }
- sleep(120);
- return 0;
- }
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- if(fork()==0)
- {
- return pstree();
- sleep(120);
- }
- sleep(120);
- return 0;
- }
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- sleep(120);
- return 0;
- }
- if(fork()==0)
- {
- printf("1 PID: %d, PPID: %d\n", getpid(), getppid());
- sleep(120);
- return 0;
- }
- sleep(120);
- return 0;
- }
- sleep(120);
- return 0;
- }
- sleep(120);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement