Thanks for this example ! - It will be moderated and published shortly.
Feel free to post other examplesOops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!
examples
0
kill -9 -1
Kill all processes you can kill.
kill -l 11
Translate number 11 into a signal name.
kill -L
List the available signal choices in a nice table.
kill 123 543 2341 3453
Send the default signal, SIGTERM, to all those processes.
0
In my ~/.bashrc file, I have added the following function :
function k(){
ps aux | grep $1 | tr -s ' ' | cut -f2 -d" " | xargs kill -9
}
then, whenever I use the command line, I can do :
k <name of software>
so :
k firefox # kills all instances of firefox, including some processes that are related
k netbeans # kills all instances of netbeans
of course, the 9 signal force the shutdown abruptly,and should only be used when you can't close a software or process, normaly.
example added by LeBerger
0
In my ~/.bashrc file, I have added the following function :
function k(){
ps aux | grep $1 | tr -s ' ' | cut -f2 -d" " | xargs kill -9
}
then, whenever I use the command line, I can do :
k <name of software>
so :
k firefox # kills all instances of firefox, including some processes that are related
k netbeans # kills all instances of netbeans
of course, the 9 signal force the shutdown abruptly,and should only be used when you can't close a software or process, normaly.
next time, when you killed everything (and are sitting in front
of the physical box), hold the Alt and SysRQ (PrintScreen) keys,
and type U S B. That means, Unmount,
Sync and re**B**oot. That will at least make
sure that unflushed changes in the filesystem get onto your
disks.
For now, boot your system in single user mode and try to run fsck
manually (maybe with -f option). Then examine your
lost+found and delete anything you are sure you don't need any
longer.
When a process remains in the process table as this process has,
then you need to kill its parent process. First, find
the parent process PID:
ps -eo 'pid,ppid,comm' | grep 97442
Then run kill <pid> for whatever the
ppid result is. (Give it a chance to die cleanly,
first.)
The traditional Unix design keeps process information around for
the parents to reap and clean up, in case the parent
processes want to run getrusage(2) to find out the
resource usage of its children, or wait(2) for their
exit status, etc.
When parents don't reap their children, the children remain
zombies -- UNTIL the parent process is killed, at which point the
kernel will re-parent the children to init(8).
init(8)will reap the newly re-parented
children.
SystemTap looks like it can't find the debug symbols for your
kernel. Have you installed the required kernel debug packages for
the kernel you are running? The SystemTap guide says:
To deploy SystemTap, you need to install the SystemTap packages
along with the corresponding set of -devel, -debuginfo and
-debuginfo-common packages for your kernel. If your system has
multiple kernels installed, and you wish to use SystemTap on
more than one kernel kernel, you will need to install the
-devel and -debuginfo packages for each of those kernel
versions.
When a python process is killed on OSX, why doesn't it kill the child processes?
On linux, when you kill a parent the child gets sent a sighup
which will generally kill it unless it was meant to stay alive as
a daemon in which case it will trap sighup. (I think this is why
one usually uses sighup to tell a daemon to refresh itself, since
it's conveneintly always trapped). On macosx I can't find
documentation but it appears that no sighup gets sent. As a
result the child process is orphaned and it's new parent is the
grandparent. The way you deal with this is you send the kill
signal to the process group of the parent not the parent process
itself. This will nuke all the children and grand children as
well with one caveate. If any child process does a setpgrp() or
setsid() then it escapes the process group membership. It will
not get the kill sent to it's old process group. Usually one need
not worry about the latter since it's usually intentional when
used to achieve that purpose.
How an unprivileged user could kill a process she didn't start?
Oracle runs its SID sub-processes as Real UID of
database owner (hri here), while the
Effective UID is Oracle's (oracle).
Which is why hri was able to kill what was
actually its own processes.
You can use ps axf -O ruid,ruser,euid,euser to
display side-by-side both RUID and EUID.
killing a process isn't instantaneous but kill exits as soon
as the signal is sent. You'll have to wait for a while before
determining if the kill command succeed or if you need to
escalate to -INT or -HUP.
kill returns(1) zero (success) if
it's allowed to send the signal. Not if it succeeds to kill the
process. So in your code only the first kill will be executed.
(1)
kill() RETURN VALUES
If successful, kill() returns a value of zero. On failure, it
returns a value of -1, does not send a signal, and sets errno to
one of the following values:
EINVAL
The value of sig is an invalid or unsupported signal number.
EPERM
The user ID of the sending process is not privileged; its real or
effective user ID does not match the real or saved user ID of the
receiving process. Or, the process does not have permission to
send the signal to any receiving process.
ESRCH
No process or process group can be found that corresponds to the
one that pid specifies.
description
The default
signal for kill is TERM. Use -l or
-L to list available signals. Particularly
useful signals include HUP, INT, KILL, STOP, CONT, and 0.
Alternate signals may be specified in three ways:
-9, -SIGKILL or
-KILL. Negative PID values may be used to
choose whole process groups; see the PGID column in ps
command output. A PID of -1 is special; it
indicates all processes except the kill process itself and
init.
options
<pid>
[...]
Send signal to every
<pid> listed.
-<signal>
-s <signal>
--signal <signal>
Specify the signal to be
sent. The signal can be specified by using name or number.
The behavior of signals is explained in signal(7)
manual page.
-l,
--list [signal]
List signal names. This option
has optional argument, which will convert signal number to
signal name, or other way round.
-L, --table
List signal names in a nice
table.
notes
Your shell (command line interpreter) may have a built-in kill
command. You may need to run the command described here as
/bin/kill to solve the conflict.
reporting bugs
Please send bug reports to procps[:at:]freelists[:dot:]org
(procps[:at:]freelists[:dot:]org)
standards
This command meets appropriate standards. The -L flag is
Linux-specific.
Albert
Cahalan (albert[:at:]users.sf[:dot:]net) wrote kill in 1999 to replace a bsdutils one
that was not standards compliant. The util-linux one might
also work correctly.
How can this site be more helpful to YOU ?
give feedback
Love it ? Hate it ? Say it !!
A problem ? An idea for a new feature ? An advice ? A command is missing ?