what is the process number you should terminate?

You start to execute a program by using the following command:
~/bigscript &
You then determine that the process is not behaving as expected, and decide that you need to terminate the process. Based on the information shown below, what is the process number you should terminate?

You start to execute a program by using the following command:
~/bigscript &
You then determine that the process is not behaving as expected, and decide that you need to terminate the process. Based on the information shown below, what is the process number you should terminate?

A.
15163

B.
15156

C.
15166

D.
15165

Explanation:
From the output exhibit we can deduce that the shell has id 15156.
It has spawned three subprocesses:
grep: id 15166
ps aef 15165
The remaining 15163 must be the subshell (see note below).
This is the id of the process which should be terminated.
Reference: man ps
Note: The command ~/bigscript &
starts ~/bigscript in a separate subshell.
echo $ displays the exit status of a command.



Leave a Reply 4

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


Mir

Mir

i don’t think A is correct…because when you open terminal solaris 11 give you bash shell and it’s have own process id…means 15163 is root shell id….
and 15156 is ~/bigscript process id…. and one more thing..that is trick please time of process id…you can find which think first execute…
i go B option.

Phumlani

Phumlani

Hi Mir,

I’m afraid B is wrong.. A is the correct answer.
It’s simple, Let put this to the test.

We both agree 15166 & 15165 are what they are… process grep that was executed last.

So that leaves 2 options, between A & B:
15156 is the process ID of your current session; here is the real life test, try it yourself. Try killing this process (or in your case the process ID you get from the cmd echo $$) and see if your login session won’t be terminated.

jack@solaris:~$ su – root
Password:
Oracle Corporation SunOS 5.11 11.1 September 2012
root@solaris:~$ echo $$
6766
root@solaris:~$ ps -aef | grep 6766
root 6766 4302 0 14:24:46 pts/1 0:00 -bash
root 6772 6766 0 14:25:09 pts/1 0:00 ps -aef
root@solaris:~$ kill -9 6766
Killed
jack@solaris:~$

As you can see when terminating the process ID from cmd echo $$, It killed my root session.
To make it even more simple; look at times sequence, You login (12:33:15); you execute script; you grep for the PIDs (12:51:45).