Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Script to kill all child process for a given PID Post 17901 by witt on Thursday 21st of March 2002 02:26:25 AM
Old 03-21-2002
No problem !
You can change the script... look this :
Code:
#!/bin/sh
while true
do
  echo "Enter parent process id  [type quit for exit]"
  read ppid

  if [ $ppid -eq "quit" -o $ppid -eq "QUIT" ];then
     exit 0
  fi

  for i in `ps -ef| awk '$3 == '$ppid' { print $2 }'`
     do
       echo killing $i
       kill $i
     done
done

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 04:42 PM..
witt
 

10 More Discussions You Might Find Interesting

1. Programming

Child Process PID

Hi, Can anybody solve this query? A parent process forks 2 child processes. How does the child process know it's PID without the parent process sending it. Apart from the "ps-ef" option, what other options are there if any? (2 Replies)
Discussion started by: skannan
2 Replies

2. Shell Programming and Scripting

In ksh, how does an in-line child sub-process get its own PID?

This is not the same as a few of the other posted items dealing with sub-process pids (that I saw anyway). If zot contains: echo "main mypid: $$ - lastpid: $!" ( echo "block mypid: $$ - lastpid: $! - ppid: $PPID" ps -ef > xxx sleep 5 echo "block mypid: $$ - lastpid: $! - ppid:... (6 Replies)
Discussion started by: MichLab
6 Replies

3. Shell Programming and Scripting

grab PID of a process and kill it in a script

#!/bin/sh who echo "\r" echo Enter the terminal ID of the user in use: echo "\r" read TERM_ID echo "\r" ps -t $TERM_ID | grep sh echo "\r" echo Enter the process number to end: echo "\r" read PID echo "\r" kill -9 $PID What this code does is ultimately grab the PID of a users sh... (6 Replies)
Discussion started by: psytropic
6 Replies

4. UNIX for Dummies Questions & Answers

How to Kill process with dynamic PID?

Hello, I have problem with killing red5 process running on linux server. As this process is continuously changing its PID so it can't be killed with "kill -9 PID" command. First I used following command to list RED5 process ps aux | grep red5 which showed me root 5832 0.0 0.0 4820 756pts/0... (1 Reply)
Discussion started by: ninadgac
1 Replies

5. Shell Programming and Scripting

How to Kill process with dynamic PID?

Hello, I have problem with killing red5 process running on linux server. As this process is continuously changing its PID so it can't be killed with "kill -9 PID" command. First I used following command to list RED5 process ps aux | grep red5 which showed me root 5832 0.0 0.0 4820 756pts/0... (4 Replies)
Discussion started by: ninadgac
4 Replies

6. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

7. Shell Programming and Scripting

Kill all child process of a script

Hi guys i have a problem with a script... this script creates differents GUI with YAD... well i want that when i press the "Cancel" button on this graphical interface all the child process and even the same script should be killed #!/bin/bash function gui_start { local choice="" ... (4 Replies)
Discussion started by: maaaaarco
4 Replies

8. Shell Programming and Scripting

Getting child process id for a given PID

HI Am trying to get child process id for a PID using ksh.. ps -ef | grep xntpd root 3342472 2228308 0 12:17:40 - 0:00 /usr/sbin/xntpd root 4522024 6488316 0 12:18:56 pts/0 0:00 grep xntpd root 6291614 3342472 0 12:17:40 - 0:00 /usr/sbin/xntpd Here now i... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

9. Shell Programming and Scripting

System should not kill the child process when parent id is 1

HI i would like to know how i can simulate a shell scripts for my requirement. example Server name child Process id Parent Process id Vpesh 16013 15637 Server name child Process id Parent Process id Vpesh 16014 15637 Server name child... (1 Reply)
Discussion started by: vpesh
1 Replies

10. Shell Programming and Scripting

Shell script to report file size, pid and also kill the process

Hi All, Looking for a quick LINUX shell script which can continuously monitors the flle size, report the process which is creating a file greater than certain limit and also kill that process. Can someone please help me on this? (4 Replies)
Discussion started by: vasavimacherla
4 Replies
tapset::context(3stap)													    tapset::context(3stap)

NAME
tapset::context - systemtap context tapset DESCRIPTION
Context functions provide additional information about where an event occurred. These functions can provide information such as a back- trace to where the event occurred and the current register values for the processor. print_regs Print a register dump See function::print_regs(3stap) for details. pp Returns the active probe point See function::pp(3stap) for details. ppfunc Returns the function name parsed from pp() See function::ppfunc(3stap) for details. probe_type The low level probe handler type of the current probe. See function::probe_type(3stap) for details. execname Returns the execname of a target process (or group of processes) See function::execname(3stap) for details. pid Returns the ID of a target process See function::pid(3stap) for details. tid Returns the thread ID of a target process See function::tid(3stap) for details. ppid Returns the process ID of a target process's parent process See function::ppid(3stap) for details. pgrp Returns the process group ID of the current process See function::pgrp(3stap) for details. sid Returns the session ID of the current process See function::sid(3stap) for details. pexecname Returns the execname of a target process's parent process See function::pexecname(3stap) for details. gid Returns the group ID of a target process See function::gid(3stap) for details. egid Returns the effective gid of a target process See function::egid(3stap) for details. uid Returns the user ID of a target process See function::uid(3stap) for details. euid Return the effective uid of a target process See function::euid(3stap) for details. is_myproc Determines if the current probe point has occurred in the user's own process See function::is_myproc(3stap) for details. cpuid Returns the current cpu number See function::cpuid(3stap) for details. cpu Returns the current cpu number See function::cpu(3stap) for details. registers_valid Determines validity of register() and u_register() in current context See function::registers_valid(3stap) for details. user_mode Determines if probe point occurs in user-mode See function::user_mode(3stap) for details. is_return Whether the current probe context is a return probe See function::is_return(3stap) for details. target Return the process ID of the target process See function::target(3stap) for details. module_name The module name of the current script See function::module_name(3stap) for details. stp_pid The process id of the stapio process See function::stp_pid(3stap) for details. remote_id The index of this instance in a remote execution. See function::remote_id(3stap) for details. remote_uri The name of this instance in a remote execution. See function::remote_uri(3stap) for details. stack_size Return the size of the kernel stack See function::stack_size(3stap) for details. stack_used Returns the amount of kernel stack used See function::stack_used(3stap) for details. stack_unused Returns the amount of kernel stack currently available See function::stack_unused(3stap) for details. addr Address of the current probe point. See function::addr(3stap) for details. uaddr User space address of current running task See function::uaddr(3stap) for details. cmdline_args Fetch command line arguments from current process See function::cmdline_args(3stap) for details. cmdline_arg Fetch a command line argument See function::cmdline_arg(3stap) for details. cmdline_str Fetch all command line arguments from current process See function::cmdline_str(3stap) for details. SEE ALSO
function::print_regs(3stap), function::pp(3stap), function::ppfunc(3stap), function::probe_type(3stap), function::execname(3stap), function::pid(3stap), function::tid(3stap), function::ppid(3stap), function::pgrp(3stap), function::sid(3stap), function::pexecname(3stap), function::gid(3stap), function::egid(3stap), function::uid(3stap), function::euid(3stap), function::is_myproc(3stap), function::cpuid(3stap), function::cpu(3stap), function::registers_valid(3stap), function::user_mode(3stap), function::is_return(3stap), function::target(3stap), function::module_name(3stap), function::stp_pid(3stap), function::remote_id(3stap), function::remote_uri(3stap), function::stack_size(3stap), function::stack_used(3stap), function::stack_unused(3stap), function::addr(3stap), function::uaddr(3stap), function::cmdline_args(3stap), function::cmdline_arg(3stap), function::cmdline_str(3stap), stap(1), stapprobes(3stap) IBM
--- tapset::context(3stap)
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy