1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
labwork [276]
3 years ago
11

Write a C program that spins a child process. The child process reads a number from the keyboard and passes the number on to the

parent process via a pipe. The parent process waits until number becomes available and reads it from the pipe, prints the number to the screen and exits.
Computers and Technology
1 answer:
Murrr4er [49]3 years ago
4 0

# include <stdio.h>

int main()

{    

   int pid;

   pid=getpid();

   printf(\"Current Process ID is : %d\\n\",pid);

   printf(\"[ Forking Child Process ... ] \\n\");    

   pid=fork(); /* This will Create Child Process and

              Returns Child\'s PID */

   if(pid < 0)

   {

       /* Process Creation Failed ... */

       exit(-1);

   }

   else if(pid==0)  

   {

       /* Child Process */

       printf(\"Child Process Started ...\\n\");

       printf(\"Child Process Completed ...\\n\");

   }

   else  

   {

       /* Parent Process */

       sleep(10);

       printf(\"Parent Process Running ... \\n\");

       printf(\"I am In Zombie State ...\\n\");

       while(1)

       {

           /*  

               Infinite Loop that Keeps the

                  Process Running

           */

       }

   }    

   return 0;

}

# include <stdio.h>

int main()

{    

   int pid;

   pid=getpid();

   printf(\"Current Process ID is : %d\\n\",pid);

   printf(\"[ Forking Child Process ... ] \\n\");    

   pid=fork(); /* This will Create Child Process and

              Returns Child\'s PID */

   if(pid < 0)

   {

       /* Process Creation Failed ... */

       exit(-1);

   }

   else if(pid==0)  

   {

       /* Child Process */

       printf(\"Child Process Started ...\\n\");

       printf(\"Child Process Completed ...\\n\");

   }

   else  

   {

       /* Parent Process */

       sleep(10);

       printf(\"Parent Process Running ... \\n\");

       printf(\"I am In Zombie State ...\\n\");

       while(1)

       {

           /*  

               Infinite Loop that Keeps the

                  Process Running

           */

       }

   }    

   return 0;

}

You might be interested in
Your bank offers to lend you $114,400 at an 8.5% annual interest rate to start your new business. The terms require you to amort
wlad13 [49]

Answer: The amount of interest to be paid is $972

Explanation: This is gotten by firstly getting the amount of money to return per year without the interest which is $114400/10(years)= 11440

11440 is to be paid per year without interest. To get amount of interest is $11440*8.5/100 = $972 this is the amount of interest to be paid per year including in year 2.

Therefore, total amount of money together with interest to be paid each year and in year 2 = $11440+$972=12412.

3 0
3 years ago
Complete the sentence.
mamaluj [8]

Answer:

We need context, it could be several answers

Explanation:

4 0
3 years ago
• R7.9 Write enhanced for loops for the following tasks.
alexdok [17]

Answer:

a is the correct answer

Explanation:

correct me if I'm wrong hope it's help thanks

3 0
2 years ago
What must you do to enable the members of the rome backup group to perform backup operations on the local system?
steposvetlana [31]
Add Rome Backup group to a membership list of a group that already has access to perform backup operations on the local system. Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions here.
5 0
3 years ago
Which type of network treats all processors equally, and allows peripheral devices to be shared without going to a separate serv
Elis [28]
The correct answer is P2P or peer-to-peer servers.

Hope I helped ;)
7 0
2 years ago
Other questions:
  • Using a windows computer, to expand a branch of the folder tree you would _____.
    14·1 answer
  • The SETI (Search for Extraterrestrial Intelligence) project collected vast amounts of data that needed processing. SETI was one
    14·1 answer
  • write a simple assembly code using 8088 microprocessor instruction set to add two numbers ? please help me if you know :(​
    11·1 answer
  • HELP ASAP!!!
    11·2 answers
  • Create and test a user-defined function named ufnFullName that combines the values of the two parameters named FirstName and Las
    15·1 answer
  • What is speaker?.....​
    13·1 answer
  • is the practice of using the internet to provide healthcare without going to a doctor’s office or hospital.
    15·1 answer
  • write a function that given an integer n returns the smallest integer greater than n the sume of whose digits is twice as big th
    13·1 answer
  • Mechanisms that can be used to rescue accident victims
    11·1 answer
  • Resource _____ let you view, manage, and automate tasks on multiple aws resources at a time.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!