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
Help ne please!! Even if I press 3 times it doenst work.. when I try to turn it off either. Any suggestions? (using ipad)​
arlik [135]

Answer: Have you tried restarting your ipad or Shutting down? Or closing your ipad and waiting for a little bit so It can leave Or you can try Pressing it harder.

Explanation:

Thats all I have to help

8 0
3 years ago
What is the main advantage that a website builder offers for web development?
Trava [24]
The correct answer is: OA. It enables people with no coding skills to create websites.
4 0
3 years ago
Read 2 more answers
______are our thoughts and feelings towards a particular subject
ddd [48]
c....attitudes.....
8 0
2 years ago
Su now wants to modify the text box that contains her numbered list. She accesses the Format Shape pane. In what ways can Su mod
Fiesta28 [93]
I believe its E she can insert a picture in the text book
7 0
3 years ago
Read 2 more answers
Given two lists: L1=[10,12,14] and L2=[20,22,24] 2
OleMash [197]

Answer:

Explanation:

(i) L1+L2  Error:

L1=[10,12,14]  

L2=[20,22,24]       # {n. 2 delete}

L1+L2  

ans =

   30    34    38

(ii) L1*2

ans =

 20    24    28

(iii) L1

L1 =

  10    12    14

8 0
2 years ago
Other questions:
  • Which of the following applications can be used as a data source for a Microsoft® Word® mail merge? A.Outlook Contacts B.Microso
    9·2 answers
  • Which of the following characteristics relates to authentication header (AH)? It is a document that defines or describes compute
    11·1 answer
  • Which of the following is a key component to your individual internet safety? government regulations
    13·1 answer
  • Can I change my brainly username?
    9·2 answers
  • Which format is best for the image below?
    12·1 answer
  • Text can be easily moved from one location to another using _____.
    15·1 answer
  • PLS PAK I ANSWER NITO KAILANGAN LANGPO​
    6·1 answer
  • What is the missing line of code?
    7·2 answers
  • Why is computer economics important?​
    10·1 answer
  • Message queues allow for programs to synchronize their operations as well as transfer data. How much data can be sent in a singl
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!