Basic Computer Knowledge Test Questions and Answers

Linux Interview Questions and Answers – Process Management

1.

What is the default maximum number of processes that can exist in Linux?

   A.) 32768
   B.) 1024 
   C.) 4096
   D.) unlimited

Answer: Option 'A'

32768

2.

How do you get parent process identification number?

   A.) waitpid
   B.) getpid()
   C.) getppid()
   D.) parentid()

Answer: Option 'C'

getppid()

3.

Parent process id of a deamon process is_________________.

   A.) 2
   B.) 3
   C.) 4
   D.) 1

Answer: Option 'D'

1

4.

The process which terminates before the parent process exits becomes

   A.) Zombie
   B.) Orphan
   C.) Child
   D.) None of these

Answer: Option 'A'

Zombie

5.

Return value of fork() system call can be:

   A.) -1,<0, 0
   B.) -1,>0, 0
   C.) -1,<0
   D.) none of these

Answer: Option 'B'

-1,>0, 0

6.

If the fork() system call returns -1, then it means?

   A.) No new child process is created
   B.) The child process is an orphan
   C.) The child process is in Zombie
   D.) none of these

Answer: Option 'A'

No new child process is created

7.

Fork returns _____ to parent process on success

   A.)
   B.) child process id
   C.) parent process id
   D.) none

Answer: Option 'B'

child process id

8.

How many times printf() will be executed in the below mentioned program?  

 
 main() 
 {
      int i;<br><br>       
      for (i = 0; i < 4; i++)      
      fork();
      printf("my pid = %d\n", getpid());
}

   A.) 4
   B.) 8
   C.) 16
   D.) 32

Answer: Option 'C'

16

9.

What is the output of the below code?
 

 
 void exit_handler1();   
 void exit_handler2();    
 int main() 
 {     
	int pid;        
	atexit(exit_handler1);      
	atexit(exit_handler2);     
	pid = fork();       
	if(pid == 0) 
	{        
		_exit(0);      
        } 
        else 
	{          
		sleep(2);            
		exit(0);     
	}     
	return 0;    
}

   A.) Only child executes the exit_handler 1 and 2
   B.) Only parent executes the exit_handler 1 and 2
   C.) Both parent and child executes the exit_handler 1 and 2
   D.) Neither parent nor child executes the exit_handler 1 and 2

Answer: Option 'B'

Only parent executes the exit_handler 1 and 2

10.

What is output of the following program?

 int main() 
 {     
	fork();       
	fork();        
	fork();       
	if (wait(0) == -1)          
	printf("leaf child\n");  
 }

   A.) “leaf child” will be printed 1 times
   B.) “leaf child” will be printed 3 times
   C.) “leaf child” will be printed 4 times
   D.) “leaf child” will be printed 8 times

Answer: Option 'C'

“leaf child” will be printed 4 times

Linux Interview Questions and Answers – Process Management Download Pdf

Recent Posts