This post was published long ago, when I was a student and an amateur blogger. The links might be broken and content may not be useful anymore. Please read this content keeping its age in mind.

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

1. b) C program that creates a child process to read commands from the standard input and execute them (a minimal implementation of a shell – like program). You can assume that no arguments will be passed to the commands to be executed.

……………………………………………………………………………………………………………………………

#include,stdio.h>

#include<unistd.h>

#include<string.h>

main()

{

int pid,n,i;

char cmd[30];

printf(“n Enter the number of commands : “);

scanf(“%d”,&n);

pid=fork();

system(“clear”);

if(!pid)

{

for(i=0;i<n;i++)

{

printf(“n Enter the command : “);

scanf(“%s”,cmd);

system(cmd);

}

}

else

{

wait(100);

exit(1);

}

printf(“n Parent process is completed..nn”);

return 0;

}

[Request : If you are going to post this program on any other website please link back to original post ]