Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Display menu until press 0 by using child process.

--------------------------------------------------------------------------------

Description : Display menu until press 0 by using child process.

/*A small program that display menu until press 0*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
main()
{
int choice;
do {
printf("---------------=====00=====---------------");
printf("

Main Menu<BR>);
printf("Please select an option that you need:<BR>);
printf(" 1. Executer ls command<BR>);
printf(" 2. Execute ps command<BR>);
printf(" 3. Execute who command<BR>);
printf(" 0. exit<BR>);
printf("
Your choice: ");
scanf("%d", &choice);
//while (getchar() != '
');
switch (choice){
case 1:
if (fork())
wait(0);
else
execlp("ls", "ls", (char *)NULL);
break;
case 2:
if (fork())
wait(0);
else
execlp("ps", "ps", (char *)NULL);
break;
case 3:
if (fork())
wait(0);
else
execlp("who", "who", (char *)NULL);
break;
case 0:
break;
default:
printf("Please enter only 0-3<BR>);
}
}
while (choice != 0);
}

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG