Question: Using C Language: This assignment uses Fork, execl , wait functions. Pretend we have an open house and your professor and you will be demonstrating

Using C Language: This assignment uses Fork, execl , wait functions. Pretend we have an open house and your professor and you will be demonstrating at least three programs you wrote to your visitors. You are guarding your computer station where you installed some top notch assignments you did in this course. You can select any three: say assign1.a.out, assign2.a.out and assign3.a.out. Some visitors may not want to see the assignments, but don't mind registering their email address with you. In this case, you would save the email address in a local file. The menu you are prompting the visitor is : main Menu: Which program would you like to run? 1. assign1.a.out 2. assign2.a.out 3. assign3.a.out 4. register your email address 5. quit The visitor presses say 2 Then your should run assign2.a.out program based on this skeleton code. I will teach fork next week. while ( 1 ) { printf ( "Which program would you like to run: Press 1 - 3 Please "); scanf ("%d", &x); pid = fork(); // creates a new process if (pid == 0) { run the program user wants...using execl or any other execl function or store the email address in a file. } else { // PARENT PROCESS IS EXECUTING // wait for the child to complete if ( x == 5 ) exit. } } // while loop // THAT IS THE END OF THE PROGRAM. // I will teach fork next. //You can store the email address in this file.

SAMPLE CODE:

#include

#include

void ChildProcess(void);

void ParentProcess(void);

void main(void)

{

pit_t pid;

pid = fork();

if (pid == 0) {

printf("I am the child ");

ChildProcess();

}

else {

printf("I am the parent, but I get the child PROCESS ID ");

printf(" *** Child process id %d *** ", pid);

ParentProcess();

}

} // end main

void ChildProcess(void)

{

int i;

printf(" *** Child process is %d *** ", getpid( ));

} // end ChildProcess

void ParentProcess(void)

{

int i;

printf(" ***Parent Process is %d *** ", getpid());

} // end Parentprocess

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!