TO DEMONSTRATE EXECLP ( ) FUNCTION
AIM:
To write a shell program to implement the execlp() function.
ALGORITHM:
1. Start the program
2. Obtain the pid value using fork() function.
3. If pid <0 , then print fork failed.
4. Else if pid = 0,execlp() function will invoked.
5. Else print child process complete.
6. Terminate the program.
PROGRAM:
#include<stdio.h>
main(int argc,char *argv[])
{
int pid;
pid=fork();
if(pid<0)
{
fprintf(stderr,”Fork failed \n”);
exit(-1);
}
elseif(pid==0)
{
execlp(“/bin/ls”,”ls”,NULL);
}
else
{
wait(NULL);
printf(“Child Complete”);
exit(0);
}
OUTPUT:
a.out fib.sh mov.c len.sh str.sh fact.sh copy.c cat.c even.c odd.sh child complete
RESULT
Thus the execlp functions were implemented
0 comments:
Post a Comment