Parent process: why not finishing and how to make finish, Operating System

Assignment Help:
#include
#include
#include
#include
#include

int main(void)
{
int pchan[2], pid, rval, cvar;
char buf[20];
if (pipe(pchan) == -1){
perror("pipe");
exit(2);
}
switch (pid = fork() ){
case -1: perror("fork");
exit(2);
case 0:
close(0);
if (dup(pchan[0] != 0)){
perror("dup");
exit(3);
}


execlp("grep", "grep", "123", NULL);
perror("exec");
exit(4);
default:

for(cvar = 0; cvar < 200; cvar++){
rval = rand();
sprintf(buf, "%d\n", rval);
write(pchan[1], buf, strlen(buf));
}
if (close(pchan[0]) == -1 || close(pchan[1]) == -1){
perror("close");
exit(4);
}

wait(NULL);
return(0);
}



}




Related Discussions:- Parent process: why not finishing and how to make finish

Determine a parser which is a variant of top-down parsing, Determine a pars...

Determine a parser which is a variant of top-down parsing without backtracking Recursive Descend parser is a variant of top-down parsing without backtracking.

How several bits are there in the logical address, Q. Regard as a logical a...

Q. Regard as a logical address space of eight pages of 1024 words every mapped onto a physical memory of 32 frames. a. How several bits are there in the logical address? b. H

What is page fault, Problem: a) The CPU can access 2 storage devices di...

Problem: a) The CPU can access 2 storage devices directly. What are these 2 storage devices? b) Define 2 key issues involved in memory management. c) How do processes sha

Inventory differences, What makes a Just-in-Time inventory system differ fr...

What makes a Just-in-Time inventory system differ from a traditional inventory system?

Interval between time of submission and completion of job, Interval among t...

Interval among the time of submission and completion of the job is known as                    Interval among the time of submission and completion of the job is known as Turn

Develop the material requirements plan, The following information is availa...

The following information is available for three MPS (Master Product Scheduling) items: Product A                            An 80 unit order is to be started in Week 3.

Explain direct sequence-analog signal, 1. A digitized voice channel is made...

1. A digitized voice channel is made by digitizing a 7 KHz bandwidth analog signal. The signal is to be sampled twice the highest frequency (two samples per hertz) . Assume each sa

List disadvantages of using a single directory, List disadvantages of using...

List disadvantages of using a single directory. Users have no privacy. Users must be careful in choosing file names, to avoid names used by others. Users may destroy each othe

What are the three main activities of an operating system, What are the thr...

What are the three main activities of an operating system in regard to memory management? Keep track of which parts of memory are now being used and by whom. Decide which pr

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd