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

How does communication takes place in a distributed system?, How does commu...

How does communication takes place in a distributed system? Distributed systems depend on the networking for their functionality. A network is a communication path among two

Characteristics of suspend process, Characteristics of suspend process ...

Characteristics of suspend process Suspended process isn't immediately available for execution. The process may or may not be waiting on an event. For preventing t

Explain User-level threads (ult), USER-LEVEL THREADS (ULT) In this lev...

USER-LEVEL THREADS (ULT) In this level the kernel isn't aware of the existence of threads -- All thread management is complete by the application by using a thread library. Th

Dynamic memory management, Usually memory is allocated from a large pool of...

Usually memory is allocated from a large pool of unused memory area called the heap. In C++, dynamic allocation/deallocation must be manually performed using commands like malloc,

What circumstances is a token-passing network more effectual, Q. In what ci...

Q. In what circumstances is a token-passing network more effectual than an Ethernet network? Answer: A token ring is extremely effective under high sustained load as no colli

Write a script in linux to match a data directory, Write a script that uses...

Write a script that uses this idea to print output similar to the following: Files in this directory that match *~ : bash-scripts.html~ chimpanzee~ countdown~ countd

Define properties to ensure good search performance, Define Properties to E...

Define Properties to Ensure Good Search Performance A hashing function h should possess the subsequent properties to make sure good search performance: a. The hashing functi

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