update busybox to v1.2.1
[openwrt-10.03/.git] / package / busybox / patches / 100-killall5.patch
1 diff -ruN busybox-1.2.0-old/include/applets.h busybox-1.2.0-new/include/applets.h
2 --- busybox-1.2.0-old/include/applets.h 2006-07-01 00:42:10.000000000 +0200
3 +++ busybox-1.2.0-new/include/applets.h 2006-07-31 00:29:34.000000000 +0200
4 @@ -157,6 +157,7 @@
5  USE_IPTUNNEL(APPLET(iptunnel, _BB_DIR_BIN, _BB_SUID_NEVER))
6  USE_KILL(APPLET(kill, _BB_DIR_BIN, _BB_SUID_NEVER))
7  USE_KILLALL(APPLET_ODDNAME(killall, kill, _BB_DIR_USR_BIN, _BB_SUID_NEVER, killall))
8 +USE_KILLALL5(APPLET_ODDNAME(killall5, kill, _BB_DIR_USR_BIN, _BB_SUID_NEVER, killall5))
9  USE_KLOGD(APPLET(klogd, _BB_DIR_SBIN, _BB_SUID_NEVER))
10  USE_LASH(APPLET(lash, _BB_DIR_BIN, _BB_SUID_NEVER))
11  USE_LAST(APPLET(last, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
12 diff -ruN busybox-1.2.0-old/include/usage.h busybox-1.2.0-new/include/usage.h
13 --- busybox-1.2.0-old/include/usage.h   2006-07-01 00:42:10.000000000 +0200
14 +++ busybox-1.2.0-new/include/usage.h   2006-07-31 00:25:57.000000000 +0200
15 @@ -1503,6 +1503,13 @@
16  #define killall_example_usage \
17         "$ killall apache\n"
18  
19 +#define killall5_trivial_usage \
20 +       ""
21 +#define killall5_full_usage \
22 +       ""
23 +#define killall5_example_usage \
24 +       ""
25 +
26  #define klogd_trivial_usage \
27         "[-c n] [-n]"
28  #define klogd_full_usage \
29 diff -ruN busybox-1.2.0-old/procps/Config.in busybox-1.2.0-new/procps/Config.in
30 --- busybox-1.2.0-old/procps/Config.in  2006-07-01 00:42:12.000000000 +0200
31 +++ busybox-1.2.0-new/procps/Config.in  2006-07-31 00:25:57.000000000 +0200
32 @@ -38,6 +38,11 @@
33           specified commands.  If no signal name is specified, SIGTERM is
34           sent.
35  
36 +config CONFIG_KILLALL5
37 +       bool "killall5"
38 +       default n
39 +       depends on CONFIG_KILL
40 +       
41  config CONFIG_PIDOF
42         bool "pidof"
43         default n
44 diff -ruN busybox-1.2.0-old/procps/kill.c busybox-1.2.0-new/procps/kill.c
45 --- busybox-1.2.0-old/procps/kill.c     2006-07-01 00:42:12.000000000 +0200
46 +++ busybox-1.2.0-new/procps/kill.c     2006-07-31 00:25:57.000000000 +0200
47 @@ -20,6 +20,7 @@
48  
49  #define KILL 0
50  #define KILLALL 1
51 +#define KILLALL5 2
52  
53  int kill_main(int argc, char **argv)
54  {
55 @@ -34,6 +35,9 @@
56  #else
57         whichApp = KILL;
58  #endif
59 +#ifdef CONFIG_KILLALL5
60 +       whichApp = (strcmp(bb_applet_name, "killall5") == 0)? KILLALL5 : whichApp;
61 +#endif
62  
63         /* Parse any options */
64         if (argc < 2)
65 @@ -112,6 +116,20 @@
66                 }
67  
68         }
69 +#ifdef CONFIG_KILLALL5
70 +       else if (whichApp == KILLALL5) {
71 +               procps_status_t * p;
72 +               pid_t myPid=getpid();
73 +               while ((p = procps_scan(0)) != 0) {
74 +                       if (p->pid != 1 && p->pid != myPid && p->pid != p->ppid) {
75 +                               if (kill(p->pid, signo) != 0) {
76 +                                       bb_perror_msg( "Could not kill pid '%d'", p->pid);
77 +                                       errors++;
78 +                               }
79 +                       }
80 +               }
81 +       }
82 +#endif
83  #ifdef CONFIG_KILLALL
84         else {
85                 pid_t myPid=getpid();