Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<unistd.h>
- int main() {
- pid_t pid;
- pid = fork();
- if (pid<0) {
- fprintf(stderr, "Fork Failed");
- return 1;
- }
- else if (pid == 0) {
- printf(“Child (pid=%d) started \n”,pid);
- execlp("/bin/ps","ps",NULL);
- }
- else {
- printf("Parent (with child pid=%d) waiting for child to complete\n",pid); wait(NULL);
- printf("Child Complete\n");
- }
- return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement