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
#Electrical Engineering
GrogVix [38]

Answer:

yes

Explanation:

where's our question

5 0
3 years ago
How many cost units are spent in the entire process of performing 40 consecutive append operations on an empty array which start
Alexus [3.1K]

Answer:

Explanation:

260 cost units, Big O(n) complexity for a push

6 0
3 years ago
Pass the two arrays to a method that will display the integer value(s), if any, that appear in both arrays (note that the two ar
vampirchik [111]

Answer:

The solution code is written in Java

  1.    public static void checkCommonValues(int arr1[], int arr2[]){
  2.        if(arr1.length < arr2.length){
  3.            for(int i = 0; i < arr1.length; i++){
  4.                for(int j = 0; j < arr2.length; j++){
  5.                    if(arr1[i] == arr2[j]){
  6.                        System.out.print(arr1[i] + " ");
  7.                    }
  8.                }
  9.            }
  10.        }
  11.        else{
  12.            for(int i = 0; i < arr2.length; i++){
  13.                for(int j = 0; j < arr1.length; j++){
  14.                    if(arr2[i] == arr1[j]){
  15.                        System.out.print(arr2[i] + " ");
  16.                    }
  17.                }
  18.            }
  19.        }
  20.    }

Explanation:

The key idea of this method is to repeated get a value from the shorter array to check against the all the values from a longer array. If any comparison result in True, the program shall display the integer.

Based on this idea, an if-else condition is defined (Line 2). Outer loop will traverse through the shorter array (Line 3, 12) and the inner loop will traverse the longer array (Line 4, 13). Within the inner loop, there is another if condition to check if the current value is equal to any value in the longer array, if so, print the common value (Line 5-7, 14-16).

5 0
3 years ago
In order to drive safely, you need to ___________. A. possess good vision B. look to the side while keeping your head and eyes s
Elena-2011 [213]
The question is vague, but answer B is absolutely incorrect so by default choice A is correct ...  "good" is hard to define and your vision can be corrected by glasses allowing you to drive, etc.
6 0
3 years ago
Please help!
Nesterboy [21]
I think it the answer would be B but I'm not sure
4 0
3 years ago
Read 2 more answers
Other questions:
  • To create a file in dos edit, type ____ at the command prompt to start dos edit, and then begin typing in the document window.
    8·1 answer
  • Nathan wants to create multiple worksheet containing common formatting styles for his team members. Which file extension helps h
    5·1 answer
  • Need deveolpers not software
    10·2 answers
  • If an employee who needs eye protection wears prescription lenses he or she should
    14·1 answer
  • What does enterprise operating system mean?
    13·1 answer
  • The Fibonacci numbers are the numbers
    15·1 answer
  • How do you copy and paste plz let me know
    14·2 answers
  • 2. Which pattern microphone should Jennifer take to the press conference? Jennifer is a journalist with one of the leading newsp
    14·1 answer
  • ________ can be written only once. The data cannot be erased or written over once it is saved.​
    9·1 answer
  • Should a UDP packet header contain both Sour Port # and Destination Port #?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!