250+ TOP MCQs on The Fork and exec System Calls

Operating System Multiple Choice Questions 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

Answer: b

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

Answer: b

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

Answer: b

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

Answer: c

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

Answer: a
Clarification: None.

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

Answer: b
Clarification: 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

Answer: b
Clarification: 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

Answer: a
Clarification: 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

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

Leave a Reply

Your email address will not be published. Required fields are marked *