0% found this document useful (0 votes)
17 views1 page

Exp 3 A

Uploaded by

22b148
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Exp 3 A

Uploaded by

22b148
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Exp3a

Program:

#include<stdio.h>

#include<stdlib.h>

#include<unistd.h>

#include<sys/wait.h>

int main(){

int pid;

pid=fork();

if(pid<0){

printf("fork failed");

exit(0); }

else if(pid==0){

execlp("/bin/ls","ls",NULL); //The list must be terminated by a NULL pointer.

printf("This code will be overwriiten by ls command"); }

else{

wait(NULL);

printf("Process id:%d",getpid());

printf("\nParent segment after child completes execution");

Output:

You might also like