You are on page 1of 4

1

Void main()

Pid_t id;

id = fork();

if(id>0)

printf(“parent finished”)

else

sleep(5);

printf(“child finished”)

#include <stdio .h>

#include <sys/wait.h>

#include <stdlib.h>

#include <unistd.h>

void main()

pid_t id;

id = fork();

if(id>o )

printf("Parent Executing \n");

sleep(5);

wait( NULL));

printf("Parent finished \n");


else

printf("Child finished \n");

exit(0);

#include <stdio.h>

#include <sys/wait.h>

#include <stdlib ole:

#incLlude <unistd h>

void main()

Pid_t id;p

id = fork();

if(id>o)

printf("Parent Executing \n");

printf("Waiting for child to finish \n");

wait( Neprintf("Parent finished \n");

printf("Child finished \n");

sleep(5);

printf("Child finished \n");

exit(0);

}
4

#include <stdio.h>

#include <sys/wait.h>

#include <stdlib.h>

#include <unistd.h>

void main()

int ex_num;

ex_num=execl("/bin/1ls", "/bin/ls", "-1lh",NULL);

#include <stdio.h>

#include <sys/wait.h>

#include <stdlib.h>

# include<unistd.h>
#include <errno.h>

int kill(pid_t pid, int sig);

void main()
{

int id;printf("Enter pid of the process you want to send signal to \n");

scanf("%d", &id);

kill(id,SIGINT);

printf("Error no is %d \n" , errno);

You might also like