Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Unexpected killall behavior

If running the command killall killall from a terminal (I used Konsole of KDE 4), it says it could not find any process. killall runs, looks for a process called killall and should find itself and kill, but it doesn't do that. Why?

share|improve this question

migrated from stackoverflow.com Mar 8 '12 at 23:23

This question came from our site for professional and enthusiast programmers.

marked as duplicate by studiohack Mar 9 '12 at 4:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

man killall | grep itself –  paislee Mar 8 '12 at 23:22
I get the (extremely corner-case) brain-teasing side of the exercise but - why would you ever want to do this? :) –  icyrock.com Mar 9 '12 at 3:26
for fun :-) :-) –  user3001 Mar 9 '12 at 11:49

2 Answers 2

up vote 10 down vote accepted

Perhaps because it's written to ignore itself?

::looks at source code for killall::



if (thispid == mypid)
share|improve this answer
So what do you think is the reason that they skip the killall process itelf - apart from "nonsense"? –  user3001 Mar 8 '12 at 23:32
@user3001 it skips it because if it killed itself, it wouldn't be able to finish the job you gave it. –  Rich Homolka Mar 9 '12 at 0:30
Indeed! Remember, killall supports regexes. A regex match could be over-eager and match killall itself while also matching the intended set of process names. E.g. killall --regex 'ki.*' or similar. Without this regex support, the feature of checking for self doesn't make much sense, since only killall can match killall. They code should skip around the test if --regex has not been specified. (By the way, it occurs to me there is gaping absence of a --glob option. You will rarely need full blown ERE on process names. If I want to kill gnome-everything, how about gnome-*. –  Kaz Mar 9 '12 at 2:26
Thank you all for your good answers :) –  user3001 Mar 9 '12 at 11:48

man killall

A killall process never kills itself (but may kill other killall processes).

share|improve this answer
True enough, but you can 2>/dev/null, and the end state is very much the same as if it had worked. –  Don Branson Mar 8 '12 at 23:25
Oh sure, make it look easy. The man page in OSX leaves that bit out :-D –  Brian Roach Mar 8 '12 at 23:25
@BrianRoach - Your way had more style ;) –  Shinrai Mar 8 '12 at 23:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.