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

Choice of operating systems to boot from, Q. How could a system be designed...

Q. How could a system be designed to allow a choice of operating systems to boot from? What would the bootstrap program need to do? Answer: Delieve a system that would like to

Windows Resources on a Network, VoIP (Voice over Internet Protocol), also c...

VoIP (Voice over Internet Protocol), also called Internet telephone, was once a novelty on the Internet, but not very useful because of all the problems with poor voice quality and

What are the services provided by the operating systems, What are the servi...

What are the services provided by the operating systems?  Program Development It provides a variety of services and facilities, such as debuggers and editor, to help the

Define a daemon process , A daemon is a process that removes itself from t...

A daemon is a process that removes itself from the terminal and disconnected, executes, in the background, waiting for requests and responding to them. It may also be described as

What is super block, What is super block A partition control block have...

What is super block A partition control block have partitions details, such as the number of blocks in the partition, size of the blocks, free-blocks and free-block pointers an

What are the benefits of thread pools, What are the benefits of thread pool...

What are the benefits of thread pools:- The benefits of thread pools are 1. It is usually faster to service a request with an existing thread than waiting to make a thread.

Single-level page tables, As mentioned above, page tables, are lookup table...

As mentioned above, page tables, are lookup tables mapping a process' virtual pages to physical pages in RAM. How would one implement these page tables? The most straightforward

Explain operating systems for mainframe computers, What are the main differ...

What are the main differences between operating systems for mainframe computers and personal computers? The design goals of operating systems for those machines are quite diffe

What are the typical elements of a process image, What are the typical elem...

What are the typical elements of a process image? User data: Modifiable part of user space. May have program data, user stack area, and programs that might be modified. User

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