Opened 17 years ago
Closed 10 years ago
#1944 closed task (no change required)
Kill command don't work with process names [Upstream to coreutils]
Reported by: | tqh | Owned by: | phoudoin |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | Applications/Command Line Tools | Version: | R1/Development |
Keywords: | Cc: | Adek336, Prasad | |
Blocked By: | Blocking: | #4687, #8162 | |
Platform: | All |
Description
In BeOS R5 I always used
kill Tracker
when needed.
Unfortunatly Haiku's 'kill' doesn't support this fantastic feature.
Attachments (2)
Change History (38)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
This bug is about kill. killall might do that, but it's not really related to the bug.
comment:3 by , 16 years ago
killall doesn't seem to be included with Haiku
~> killall sh: killall: command not found
it'd be cool to have it, though.
comment:4 by , 16 years ago
Cc: | added |
---|
comment:5 by , 14 years ago
In R5, if you have several instances of a process named, let say "test", did kill test terminate them all or the first it found, or?
comment:6 by , 13 years ago
Blocking: | 8162 added |
---|
comment:7 by , 13 years ago
Blocking: | 4687 added |
---|
comment:8 by , 13 years ago
Component: | Applications → Applications/Command Line Tools |
---|
by , 12 years ago
Attachment: | 0001-killall-add-killall-command.patch added |
---|
comment:9 by , 12 years ago
patch: | 0 → 1 |
---|
comment:10 by , 12 years ago
Cc: | added |
---|
follow-up: 12 comment:11 by , 12 years ago
It would be nice to have this functionality in kill without adding one more tool.
follow-up: 13 comment:12 by , 12 years ago
Replying to diver:
It would be nice to have this functionality in kill without adding one more tool.
Yeah, but it really isn't the posix way. killall is more correct.
follow-up: 14 comment:13 by , 12 years ago
Replying to kallisti5:
Yeah, but it really isn't the posix way. killall is more correct.
That may be the case, but we're not always aiming to limit ourselves to exactly what the posix spec says. In this case, I'd say it's more convenient to the user to also support it in kill, which I might add R5 did as well.
follow-up: 15 comment:14 by , 12 years ago
Replying to anevilyak:
Replying to kallisti5:
Yeah, but it really isn't the posix way. killall is more correct.
That may be the case, but we're not always aiming to limit ourselves to exactly what the posix spec says. In this case, I'd say it's more convenient to the user to also support it in kill, which I might add R5 did as well.
Ah.. if R5 did it then yeah, kill may be the better place for this :)
comment:15 by , 12 years ago
Replying to kallisti5:
Replying to anevilyak:
Replying to kallisti5:
Yeah, but it really isn't the posix way. killall is more correct.
That may be the case, but we're not always aiming to limit ourselves to exactly what the posix spec says. In this case, I'd say it's more convenient to the user to also support it in kill, which I might add R5 did as well.
Ah.. if R5 did it then yeah, kill may be the better place for this :)
killall has lots of switches for example killing group, regex search, checking the process running specific path. If kill command cannot support all of them, then I would suggest we do both.
I am not sure all the options supported by kill on R5. It would be great if anyone can print the usage message for kill command.
follow-up: 17 comment:16 by , 12 years ago
$ kill Usage : kill [-SIGNAME] pid1 [pid2 ...] where SIGNAME is one of INT, HUP, KILL, etc
comment:17 by , 12 years ago
Replying to diver:
$ kill Usage : kill [-SIGNAME] pid1 [pid2 ...] where SIGNAME is one of INT, HUP, KILL, etc
Seems like R5 too does not support kill <name>
. There is no such option.
follow-up: 22 comment:18 by , 12 years ago
Nah, R5 does support this feature even though it's not exposed in its' usage text.
In other words kill Tracker worked fine.
comment:19 by , 12 years ago
I think adding name support to kill is fine, but in general for this sort of thing "hey Tracker QUIT" is nicer, at least for BApplications.
comment:21 by , 12 years ago
Cc: | added; removed |
---|---|
Version: | R1/pre-alpha1 → R1/Development |
comment:22 by , 12 years ago
Replying to diver:
Nah, R5 does support this feature even though it's not exposed in its' usage text.
In other words kill Tracker worked fine.
Haiku uses kill command which is by default built into the shell (not /bin/kill). The code in this command does not access the system wide list of processes. It works mostly with the list of processes ran on the current shell. One one exception to this is when kill is invoked with a pid, however it directly uses the PID and does no search.
We can add a special case for kill <name>
and write the code to look for all the processes running in the system. However, that defeats the purpose of using shell builtin command.
After a small modification in the code, it was possible to kill the current shell jobs using process name. However, it did not kill processes ran by on other shell. For example:
~> jobs # NOTE NO JOBS RUNNING IN BACKGROUND ~> ps Team Id #Threads Gid Uid kernel_team 1 32 0 0 /boot/system/servers/registrar 48 6 0 0 /boot/system/servers/debug_server 55 2 0 0 /boot/system/servers/net_server 56 4 0 0 /boot/system/servers/app_server 57 26 0 0 /boot/system/servers/syslog_daemon 72 2 0 0 /boot/system/servers/input_server 84 9 0 0 /boot/system/servers/mount_server 94 1 0 0 /boot/system/Tracker 106 7 0 0 /boot/system/Deskbar 107 2 0 0 /boot/system/servers/media_server 108 6 0 0 /boot/system/servers/midi_server 109 3 0 0 /boot/system/servers/print_server 110 2 0 0 /boot/system/servers/cddb_daemon 112 1 0 0 /boot/system/servers/notification_server 113 2 0 0 /boot/system/servers/power_daemon 114 1 0 0 /boot/system/servers/media_addon_server 152 5 0 0 /boot/system/apps/LaunchBox 217 2 0 0 /boot/system/apps/Terminal 242 6 0 0 /bin/bash -l 246 1 0 0 /bin/bash -l 263 1 0 0 /bin/sleep 10000 278 1 0 0 /bin/ps 279 1 0 0 ~> kill -9 sleep bash: kill: sleep: no such job ~> sleep 1000 & # RAN A PROCESS IN BACKGROUND [1] 281 ~> ps Team Id #Threads Gid Uid kernel_team 1 32 0 0 /boot/system/servers/registrar 48 6 0 0 /boot/system/servers/debug_server 55 2 0 0 /boot/system/servers/net_server 56 4 0 0 /boot/system/servers/app_server 57 26 0 0 /boot/system/servers/syslog_daemon 72 2 0 0 /boot/system/servers/input_server 84 9 0 0 /boot/system/servers/mount_server 94 1 0 0 /boot/system/Tracker 106 7 0 0 /boot/system/Deskbar 107 2 0 0 /boot/system/servers/media_server 108 6 0 0 /boot/system/servers/midi_server 109 3 0 0 /boot/system/servers/print_server 110 2 0 0 /boot/system/servers/cddb_daemon 112 1 0 0 /boot/system/servers/notification_server 113 2 0 0 /boot/system/servers/power_daemon 114 1 0 0 /boot/system/servers/media_addon_server 152 5 0 0 /boot/system/apps/LaunchBox 217 2 0 0 /boot/system/apps/Terminal 242 6 0 0 /bin/bash -l 246 1 0 0 /bin/bash -l 263 1 0 0 /bin/sleep 10000 278 1 0 0 /bin/sleep 1000 281 1 0 0 /bin/ps 282 1 0 0 ~> jobs # ONE JOB RUNNING [1]+ Running sleep 1000 & ~> kill -9 sleep killing this process. ~> jobs [1]+ Kill Thread sleep 1000 ~> ps Team Id #Threads Gid Uid kernel_team 1 32 0 0 /boot/system/servers/registrar 48 6 0 0 /boot/system/servers/debug_server 55 2 0 0 /boot/system/servers/net_server 56 4 0 0 /boot/system/servers/app_server 57 26 0 0 /boot/system/servers/syslog_daemon 72 2 0 0 /boot/system/servers/input_server 84 9 0 0 /boot/system/servers/mount_server 94 1 0 0 /boot/system/Tracker 106 7 0 0 /boot/system/Deskbar 107 2 0 0 /boot/system/servers/media_server 108 6 0 0 /boot/system/servers/midi_server 109 3 0 0 /boot/system/servers/print_server 110 2 0 0 /boot/system/servers/cddb_daemon 112 1 0 0 /boot/system/servers/notification_server 113 2 0 0 /boot/system/servers/power_daemon 114 1 0 0 /boot/system/servers/media_addon_server 152 5 0 0 /boot/system/apps/LaunchBox 217 2 0 0 /boot/system/apps/Terminal 242 6 0 0 /bin/bash -l 246 1 0 0 /bin/bash -l 263 1 0 0 /bin/sleep 10000 278 1 0 0 /bin/ps 283 1 0 0
To summarize
- Changes to support name killing are possible in builtin, however they are not recommended (according to me).
- We can do necessary modification in the non-builtin kill command. However, the command must be invoked using full path of the command
/bin/kill
- Change
/bin/kill
and remove bulitin kill.
comment:23 by , 12 years ago
BeOS R5:
$ type kill kill is hashed (/bin/kill)
Haiku:
~> type kill kill is a shell builtin
comment:24 by , 12 years ago
The simple fact that there is not /bin/kill under Haiku is already a potential binary compatibility issue, if a BeOS app was running it outside a shell context (read exec() vs system() for example).
So I'm for moving to genuine /bin/kill command tool and, obviously, add process name support in the... well, same process ;-)
by , 12 years ago
Attachment: | 0001-Add-support-to-kill-processes-using-their-names.patch added |
---|
comment:26 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
+1 to this patch, with the exception that some of the variable names in the new functions in kill are too short (e and n in is_number(), and tm, tc, p and q in kill_by_name().) In addition the "int l" in kill_by_name is not used, as far as I can see.
Overall, very nice patch Prasad! If Prasad is around and willing to fix the variable names, please do. Otherwise I'll apply this patch and fix the variable names myself before the end of the week.
comment:27 by , 12 years ago
Any news on this ticket? Would be a very useful feature the ability to kill a process by its name! :-)
comment:28 by , 12 years ago
Well, I guess leavengood's week is not ended yet ;-) If he don't beat me, I'll fix and apply it.
comment:29 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | assigned → in-progress |
comment:30 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | in-progress → closed |
Applied with some style and code cleanup in hrev45523. Thanks.
follow-up: 34 comment:31 by , 12 years ago
Hey Phoudoin, thanks to you for this little but very useful improvement! :-)
comment:32 by , 12 years ago
Type: | bug → enhancement |
---|
Re-opened to not forget this should make this upstream compliant, as suggested by mmu_man.
comment:33 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:34 by , 12 years ago
Replying to Giova84:
Hey Phoudoin, thanks to you for this little but very useful improvement! :-)
What's 5 years waiting for such improvement? ;-)
comment:35 by , 10 years ago
Milestone: | R1 → Unscheduled |
---|---|
Summary: | Kill command don't work with process names → Kill command don't work with process names [Upstream to coreutils] |
Type: | enhancement → task |
comment:36 by , 10 years ago
Resolution: | → no change required |
---|---|
Status: | reopened → closed |
The "kill" command now uses the Bash builtin. Also, GNU would not accept our patch anyway, as they have another utility ("killall") that does this.
If you're experiencing some other problem with the patched Bash kill, please file a ticket at HaikuPorts.
Isn't killall is used for that?