
- Forum
- Operating Systems
- Shell Programming
- Want to Kill the Process
Want to Kill the Process
This is a discussion on Want to Kill the Process within the Shell Programming forums, part of the Operating Systems category; My shell script has a main program that runs as a main parent. There are many scripts called from this ...
-
Want to Kill the Process
My shell script has a main program that runs as a main parent. There are many scripts called from this main parent process. Each of these child process returns to the parent after execution. But I want to kill the child process before it returns to the main parent program. I am struck with this step. Someone provide me suggestions for doing this.
-
Each process has a process id associated with it. It is this process id which will help us in deleting the process or accessing the process a user requires. For your requirement first you must get the process id of the last background process. This can be got by using the command $!.The command returns the process id of the last background process. Also get the process id of the current process in execution using the command $$. Now to kill the child process after its execution and return to your main process use the command kill -1 followed by the process id of the last background process stored in $!. Give this in the main process and your last child process would get killed.

Reply With Quote





