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

Advantages and disadvantages of using circuit switching, Q. What are the ad...

Q. What are the advantages as well as disadvantages of using circuit switching? For what types of applications is circuit switching a viable strategy? Answer: Circuit

Explain file, What is a file? A named collection of related data explai...

What is a file? A named collection of related data explained by the creator, recorded on secondary storage.

Roles of operating systems, Describe Three major roles of operating systems...

Describe Three major roles of operating systems in business computer systems

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

Differences among user-level threads and kernel-level thread, Q. What are t...

Q. What are two differences among user-level threads and kernel-level threads? Under what situations is one type better than the other? Answer: (1) User-level threads are un

Explain next fit algorithm, NEXT FIT ALGORITHM Here scanning starts fro...

NEXT FIT ALGORITHM Here scanning starts from the first fit position and then it finds the next position which is large sufficient to hold the process. Thus the name next fit.

What effect would updating a few byte on the one page, Q. What is the effe...

Q. What is the effect of permitting two entries in a page table to point to the same page frame in memory? Describe how this effect could be used to decrease the amount of time ne

Determine a policy that is not valid page replacement policy, Determine a p...

Determine a policy that is not a valid page replacement policy?  RU policy (Recurrently used) is not a valid page replacement policy.

Explai basic concepts of demand paging, Basic concepts When a process i...

Basic concepts When a process is to be changed in, the pager guesses which pages will be used before the process is changed out again. Instead of swapping in a entire process,

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