Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Cpp

Visibility

unlisted

Author

legacy-anonymous

Created

2018-03-19T10:06:16Z

Updated

2018-03-19T10:06:16Z

#include <cstdio>
#include <cstdlib>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main()
{
	pid_t pid;
	pid = fork();
	if (pid< 0) 
	{ 
		/* error occurred */ 
		fprintf(stderr, "Fork Failed"); 
		exit(-1); 
	}
	else if (pid == 0)
	{ /* child process */ 
		execlp("/bin/ls", "ls", NULL); 
		exit(0);
	}
	else 
	{ /* parent process */ /* parent will wait for the child to complete */ 
		//wait(NULL); 
		printf("Child Complete\n"); 
		exit(0); 
	}

    printf("hello from OS_0!\n");
    return 0;
}
INFO