[haiku-bugs] Re: [Haiku] #1944: Kill command don't work with process names

  • From: "Prasad" <trac@xxxxxxxxxxxx>
  • Date: Thu, 25 Oct 2012 16:50:52 -0000

#1944: Kill command don't work with process names
-----------------------------------------------+---------------------------
   Reporter:  tqh                              |      Owner:  axeld
       Type:  bug                              |     Status:  new
   Priority:  normal                           |  Milestone:  R1
  Component:  Applications/Command Line Tools  |    Version:
 Resolution:                                   |  R1/Development
 Blocked By:                                   |   Keywords:
Has a Patch:  1                                |   Blocking:  4687, 8162
                                               |   Platform:  All
-----------------------------------------------+---------------------------

Comment (by Prasad):

 Replying to [comment:18 diver]:
 > Nah, R5 does support this feature even though it's not exposed in its'
 usage text. [[BR]]
 > 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
 ------------
 1. Changes to support name killing are possible in builtin, however they
 are not recommended (according to me).

 2. 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}}}

 3. Change {{{/bin/kill}}} and remove bulitin kill.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/1944#comment:22>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: