Operating System Questions and Answers – The Fork and exec System Calls

This set of Operating System Multiple Choice Questions & Answers (MCQs) focuses on “The Fork and exec System Calls”.

1. Which of the following system calls does not return control to the calling point, on termination?
a) fork
b) exec
c) ioctl
d) longjmp
View Answer

Answer: b
Explanation: None.

2. The following program results in the creation of?

   main()
   {
      if(fork()>0)
      sleep(100);
   }

a) an orphan process
b) a zombie process
c) a process that executes forever
d) none of the mentioned
View Answer

Answer: b
Explanation: None.
advertisement
advertisement

3. Which of the following system calls transforms executable binary file into a process?
a) fork
b) exec
c) ioctl
d) longjmp
View Answer

Answer: b
Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. How many times the following C program prints yes?

 main()
   {
     fork();fork();printf("yes");
   }

a) only once
b) twice
c) four times
d) eight times
View Answer

Answer: c
Explanation: None.
advertisement

5. Which of the following calls never returns an error?
a) getpid
b) fork
c) ioctl
d) open
View Answer

Answer: a
Explanation: None.
advertisement

6. A fork system call will fail if ______________
a) the previously executed statement is also a fork call
b) the limit on the maximum number of processes in the system would be executed
c) the limit on the minimum number of processes that can be under execution by a single user would be executed
d) all of the mentioned
View Answer

Answer: b
Explanation: None.

7. If a thread invokes the exec system call ____________
a) only the exec executes as a separate process
b) the program specified in the parameter to exec will replace the entire process
c) the exec is ignored as it is invoked by a thread
d) none of the mentioned
View Answer

Answer: b
Explanation: None.

8. If exec is called immediately after forking ____________
a) the program specified in the parameter to exec will replace the entire process
b) all the threads will be duplicated
c) all the threads may be duplicated
d) none of the mentioned
View Answer

Answer: a
Explanation: None.

9. If a process does not call exec after forking ____________
a) the program specified in the parameter to exec will replace the entire process
b) all the threads should be duplicated
c) all the threads should not be duplicated
d) none of the mentioned
View Answer

Answer: b
Explanation: The new process is purely based on fork, due to no exec command, duplication will be done.

Sanfoundry Global Education & Learning Series – Operating System.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.