Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

We recently discovered that GNU kill, going beyond spec, will take a name as its argument and try to kill all processes with that name, in the same vein as pkill(1) or some implementations of killall.

I haven't been able to find GNU's changelog for kill. When was that "feature" added?

share|improve this question
    
Neither my builtin kill nor /bin/kill ("procps version 3.2.8") accept a name...? –  Kevin Nov 28 '11 at 22:39
    
@Kevin thanks for the feedback. I added a link to the manpage that matches the version of kill I'm dealing with. (If I read that correctly the feature was introduced by Salvatore Valente, which I didn't notice before. I suppose I could email him, but that seems presumptuous when there must be a changelog out there somewhere.) –  kojiro Nov 28 '11 at 22:51
2  
the man page you have mentioned is man page for bsd kill and not for gnu kill. –  Sachin Divekar Nov 28 '11 at 22:55
3  
@SachinDivekar It's not BSD kill either. That particular implementation of kill is specific to Linux, and the feature doesn't seem to have existed on classic BSD either (e.g. 4.4BSD). –  Gilles Nov 28 '11 at 23:19
1  
@Gilles, yes you are right. I checked the man page again. It says Linux Utilities at the bottom left. Plus in AUTHER section it is mentioned that Taken from BSD 4.4. The ability to translate process names to process ids was added by Salvatore Valente. So, the man page is for Linux and it is taken and updated from BSD 4.4 version. –  Sachin Divekar Nov 28 '11 at 23:26
show 2 more comments

migrated from serverfault.com Nov 28 '11 at 22:28

This question came from our site for professional system and network administrators.

1 Answer

up vote 6 down vote accepted

You can browse the source of Gnu coreutils on Savannah (or clone the repository on your machine), and in particular look at the source and the changelog of the kill utility. There is not and has never been such a feature.

do {
      intmax_t n = (errno = 0, strtoimax (arg, &endp, 10));
      …
      if (errno == ERANGE || pid != n || arg == endp || *endp)
        {
          error (0, 0, _("%s: invalid process id"), arg);
          status = EXIT_FAILURE;
        }
      …
} while ((arg = *++argv));

The manpage you link to is for the kill command from the util-linux collection. As you can see from the date of the man page, this feature is very old. Many Linux systems ship the kill command from GNU coreutils, or the one from the procps package, and most of the time you'll see your shell's builtin rather than the external command anyway. None of these allow you to pass a bare command name as an argument.

On a related note, in bash, ksh and zsh, you can pass any job specification as an argument to kill. Job specifications start with a % and can be followed by a job number or by a part of the name of the command of that job.

$ jobs
[3] +  Running                 sleep 9999 &
[2] - Stopped                  vim foo
[1]    Running                 xterm &
$ kill %sleep
[3] + Terminated               sleep 9999 &
$ jobs
[2] + Stopped                  vim foo
[1] -  Running                 xterm &
share|improve this answer
1  
What happened here is that someone used sudo kill java when he meant to do sudo killjava (where killjava is a local script). Sudo bypassed the shell builtin, and I was trying to figure out why /bin/kill behaved differently. I'm surprised, but pleased, to discover that GNU was not the culprit this time. –  kojiro Nov 28 '11 at 23:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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