|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| ARCHIVES - Tips, Tricks & Tweaks Tips and Solutions for SUSE Linux
(Please do not post questions here) |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Quote:
The -9 (or -KILL) argument to kill(1) should never be used on Unix systems, except as a very last resort. The KILL signal does not allow a process to run any cleanup code, which means blasting away with kill -9 may leave child processes of a parent orphaned, temporary files open, shared memory segments active, and sockets busy. This leaves the system in a messy state, and could lead to unanticipated and hard to debug problems. Code:
$ kill -9 1435 Code:
$ kill 1435 $ kill -INT 1435 $ kill -HUP 1435 $ kill -KILL 1435 If KILL does not cause a process to exit, then the process is most likely involved with the Unix kernel somehow. Good luck! Killing from Scripts Using a Bourne-based shell such as bash or zsh, escalating kill calls can be automated. The following cycle_kill function is used in the script reallykill. Code:
cycle_kill () {
PID=$1
RETVAL=0
for signal in "TERM" "INT" "HUP" "KILL"; do
kill -$signal $PID
RETVAL=$?
[ $RETVAL -eq 0 ] && break
echo "warning: kill failed: pid=$PID, signal=$signal" >&2
sleep 1
done
return $RETVAL
}
cycle_kill 1435
Code:
$ kill 1435 $ reallykill 1435 warning: kill failed: pid=1435, signal=TERM warning: kill failed: pid=1435, signal=INT Code:
for my $signal (qw{TERM INT HUP KILL}) {
last if kill $signal, $pid;
warn "warning: kill failed: pid=$pid, signal=$signal\n";
sleep 1;
}
Signals
For more information on kill signals, see kill(1) or run kill -l for a list of signals supported on the system in question. |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|