Enter your email address & Win:

System Software Lab Programs ( UNIX Programs ) – 1B

// March 4th, 2009 // Engineering, Unix and System Software Lab // Written by sandeephegde

-->

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..\n\n”);

return 0;

}

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


If you enjoyed this post, make sure you subscribe to my RSS feed!

Related posts:

  1. System Software Lab Programs ( UNIX Programs ) – 4b
  2. System Software Lab Programs ( UNIX Programs ) – 5b
  3. System Software Lab Programs ( UNIX Programs ) – 7b
  4. System Software Lab Programs ( UNIX Programs ) – 3b
  5. System Software Lab Programs ( UNIX Programs ) – 6b
blog comments powered by Disqus
Get Adobe Flash playerPlugin by wpburn.com wordpress themes