Are file descriptors of a parent inherited by child process

Assignment Help Computer Engineering
Reference no: EM132094010

Please answer the following questions based on the C code for Program1A.c and Program1B.c

1. Are any of the variables of a parent shared with any of its child processes? Do the children of the same parent share some variables between themselves?

2. Are file descriptors of a parent inherited by child processes? Specifically, if a file Project1.txt is opened by a parent and kept open across a call to fork, is Project1.txt still open in the child process? If the answer is yes, when a child process reads blocks from Project1.txt, will the parent remain at the same position in Project1.txt?

3. Remember that the wait and exit calls can be used for communication between a parent process and its child processes. Now modify Project1A.c so that the parent process terminates only after BOTH its child processes have terminated.

4. Is it allowed for a parent to terminate before one of its child processes has terminated? If so, does this affect the child processes in any way?

Is it possible for the parent process in Project1A.c to terminate one of its child processes, say A1 or A2? Now, is it possible for the parent process in Project1B.c to terminate one of its grandchild processes, say A1 or A2? If so, how? Hint: Using exit to pass data between the child and parent will not work in this case. For details, see the man page for wait.

Project1A.c

#include
#include

int main()
{
pid_t pid1, pid2;
pid1 = fork();
if (pid1 == 0) { // child process
printf("Child process A1 created\n");
}
else {
pid2 = fork();
if (pid2 == 0) { // 2nd child process
printf("Child process A2 created\n");
} else{
waitpid(pid2,0,0); // wait till child process ends
waitpid(pid1,0,0); // wait till child process ends
}
}
return 0;
}

Project1B.c

#include
#include


int main()
{
pid_t pid1;
pid1 = fork();
if (pid1 == 0) { // child process
execv("Project1A",NULL); // run another process named Project1A
exit(127);
} else {
waitpid(pid1,0,0); // wait till child process ends
}

return 0;
}

Reference no: EM132094010

Questions Cloud

Write a program that creates an array of 1000 random numbers : Write a program that creates an array of 1000 random numbers in the range 1 - 5000. Then ask the user for a value between and 5000.
What are the purposes of control flow testing : What are the purposes of Control Flow testing and who needs to conduct Control Flow testing?
Describe such an attack : It is even easier to solve the Hill cipher if a chosen plaintext attack can be mounted. Describe such an attack.
Consider the various training and development formats : Consider the various training and development formats described in chapter 8. Which three do you think would be most effective for developing the skills
Are file descriptors of a parent inherited by child process : Is it allowed for a parent to terminate before one of its child processes has terminated? If so, does this affect the child processes in any way?
Contemporary leadership competencies : You have become comfortable with contemporary leadership competencies and feel it is time to open your own small business. As a future business
Discuss how employers can justify the use of tools : Privacy goes hand in hand with security, but many of the activities of information security analysts seem to be an invasion of privacy.
Expected results of implementing your communication plan : You will need to review the products you created and describe what those products are and how they work together. A conclusion that specifies the expected
Explain what communication-conflict management : Explain what communication/conflict management strategy would be effective to eliminate anger felt by the two directors not chosen?

Reviews

Write a Review

Computer Engineering Questions & Answers

  How you would start the given incident off correctly

You have been asked by management to secure the laptop computer of an individual who was just dismissed from the company under unfavorable circumstances.

  Create a class named package with data fields for weight

Create a class named Package with data fields for weight in ounces (oz.), shipping method, and shipping cost.

  How does the arithmetic mean compare on random integers

How does the arithmetic and geometric mean compare on random integers? Show that the arithmetic mean equals the geometric mean when all terms are the same.

  Write a recursive program to compute height of a binary tree

Write a recursive program to compute the height of a binary tree: the longest distance from the root to an external node.

  Calculate and show the mortgage payment amount

Write down the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. Allow th..

  Provide a prototype of website design and architecture

Draw Context Level diagram. Provide a prototype of website design and architecture you have developed based on the case study.

  Develop and test a python program to track student marks

Design, develop and test a python program to track student marks in the various assignments in a given unit of study.

  What is the maximum directly addressable memory

A microcontroller with 24 address pins and eight data pins is connected to a 1K × 8 memory with one enable. How many unused address bits of the microcontroller.

  1 the project could fail because the cost of a key

1. the project could fail because the cost of a key component has increased and we could build a product that does not

  Concept of inheritance and object hierarchy

Study the concept of inheritance and object hierarchy in the object-oriented programming.

  Discuss about the security considerations

As is true with all components in any computing environment, security considerations are paramount for operating systems as well. Performing risk assessments.

  What would be the representation 010 in 16-bit binary

Express 159 base10 and -98 base10 in 8-bit binary one's complement form and then add the numbers.

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