diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-07-21 21:32:12 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-07-21 21:32:12 +0000 |
commit | bf960f58e2fc56402cc5c3c090d90b706a4de5f2 (patch) | |
tree | ad4f94b99f7e82e9e4a1245c271ef4962b16e764 | |
parent | 7df345e1494e61ad94dd03f9a48f8e5b52a21d2b (diff) | |
download | busybox-w32-bf960f58e2fc56402cc5c3c090d90b706a4de5f2.tar.gz busybox-w32-bf960f58e2fc56402cc5c3c090d90b706a4de5f2.tar.bz2 busybox-w32-bf960f58e2fc56402cc5c3c090d90b706a4de5f2.zip |
Added 'renice' command, thanks to Dave Cinege <dcinege@psychosis.com>
-Erik
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | applets/busybox.c | 6 | ||||
-rw-r--r-- | applets/usage.c | 12 | ||||
-rw-r--r-- | busybox.c | 6 | ||||
-rw-r--r-- | busybox.def.h | 1 | ||||
-rw-r--r-- | docs/busybox.pod | 14 | ||||
-rw-r--r-- | docs/busybox.sgml | 16 | ||||
-rw-r--r-- | internal.h | 2 | ||||
-rw-r--r-- | procps/renice.c | 53 | ||||
-rw-r--r-- | renice.c | 53 | ||||
-rw-r--r-- | usage.c | 12 |
11 files changed, 171 insertions, 5 deletions
@@ -1,5 +1,6 @@ | |||
1 | 0.47pre | 1 | 0.47pre |
2 | 2 | ||
3 | * added 'renice' command -- thanks to Dave Cinege <dcinege@psychosis.com> | ||
3 | * 'make install' now creates relative symlinks, and added a new | 4 | * 'make install' now creates relative symlinks, and added a new |
4 | 'make install-hardlinks' target to (tada) install hardlinks. | 5 | 'make install-hardlinks' target to (tada) install hardlinks. |
5 | * syslogd can now log messages to a remote host -- patch thanks | 6 | * syslogd can now log messages to a remote host -- patch thanks |
diff --git a/applets/busybox.c b/applets/busybox.c index 0c291d0c5..5b19e8a16 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
@@ -250,6 +250,9 @@ const struct BB_applet applets[] = { | |||
250 | #ifdef BB_REBOOT | 250 | #ifdef BB_REBOOT |
251 | {"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage}, | 251 | {"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage}, |
252 | #endif | 252 | #endif |
253 | #ifdef BB_RENICE | ||
254 | {"renice", renice_main, _BB_DIR_USR_BIN}, | ||
255 | #endif | ||
253 | #ifdef BB_RM | 256 | #ifdef BB_RM |
254 | {"rm", rm_main, _BB_DIR_BIN, rm_usage}, | 257 | {"rm", rm_main, _BB_DIR_BIN, rm_usage}, |
255 | #endif | 258 | #endif |
@@ -484,8 +487,9 @@ int main(int argc, char **argv) | |||
484 | #ifdef BB_SH | 487 | #ifdef BB_SH |
485 | /* Add in a special case hack -- whenever **argv == '-' | 488 | /* Add in a special case hack -- whenever **argv == '-' |
486 | * (i.e. '-su' or '-sh') always invoke the shell */ | 489 | * (i.e. '-su' or '-sh') always invoke the shell */ |
487 | if (**argv == '-') | 490 | if (**argv == '-' && *(*argv+1)!= '-') { |
488 | exit(((*(shell_main)) (argc, argv))); | 491 | exit(((*(shell_main)) (argc, argv))); |
492 | } | ||
489 | #endif | 493 | #endif |
490 | 494 | ||
491 | while (a->name != 0) { | 495 | while (a->name != 0) { |
diff --git a/applets/usage.c b/applets/usage.c index 1031f24bc..3f367f9b1 100644 --- a/applets/usage.c +++ b/applets/usage.c | |||
@@ -859,6 +859,18 @@ const char reboot_usage[] = | |||
859 | ; | 859 | ; |
860 | #endif | 860 | #endif |
861 | 861 | ||
862 | |||
863 | #if defined BB_RENICE | ||
864 | const char renice_usage[] = | ||
865 | "renice priority pid [pid ...]\n" | ||
866 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
867 | "\nChanges priority of running processes. Allowed priorities range\n" | ||
868 | "from 20 (the process runs only when nothing else is running) to 0\n" | ||
869 | "(default priority) to -20 (almost nothing else ever gets to run).\n" | ||
870 | #endif | ||
871 | ; | ||
872 | #endif | ||
873 | |||
862 | #if defined BB_RM | 874 | #if defined BB_RM |
863 | const char rm_usage[] = | 875 | const char rm_usage[] = |
864 | "rm [OPTION]... FILE...\n" | 876 | "rm [OPTION]... FILE...\n" |
@@ -250,6 +250,9 @@ const struct BB_applet applets[] = { | |||
250 | #ifdef BB_REBOOT | 250 | #ifdef BB_REBOOT |
251 | {"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage}, | 251 | {"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage}, |
252 | #endif | 252 | #endif |
253 | #ifdef BB_RENICE | ||
254 | {"renice", renice_main, _BB_DIR_USR_BIN}, | ||
255 | #endif | ||
253 | #ifdef BB_RM | 256 | #ifdef BB_RM |
254 | {"rm", rm_main, _BB_DIR_BIN, rm_usage}, | 257 | {"rm", rm_main, _BB_DIR_BIN, rm_usage}, |
255 | #endif | 258 | #endif |
@@ -484,8 +487,9 @@ int main(int argc, char **argv) | |||
484 | #ifdef BB_SH | 487 | #ifdef BB_SH |
485 | /* Add in a special case hack -- whenever **argv == '-' | 488 | /* Add in a special case hack -- whenever **argv == '-' |
486 | * (i.e. '-su' or '-sh') always invoke the shell */ | 489 | * (i.e. '-su' or '-sh') always invoke the shell */ |
487 | if (**argv == '-') | 490 | if (**argv == '-' && *(*argv+1)!= '-') { |
488 | exit(((*(shell_main)) (argc, argv))); | 491 | exit(((*(shell_main)) (argc, argv))); |
492 | } | ||
489 | #endif | 493 | #endif |
490 | 494 | ||
491 | while (a->name != 0) { | 495 | while (a->name != 0) { |
diff --git a/busybox.def.h b/busybox.def.h index 2c98af40d..a9f54eaef 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -73,6 +73,7 @@ | |||
73 | #define BB_PS | 73 | #define BB_PS |
74 | #define BB_PWD | 74 | #define BB_PWD |
75 | #define BB_REBOOT | 75 | #define BB_REBOOT |
76 | #define BB_RENICE | ||
76 | #define BB_RM | 77 | #define BB_RM |
77 | #define BB_RMDIR | 78 | #define BB_RMDIR |
78 | #define BB_RMMOD | 79 | #define BB_RMMOD |
diff --git a/docs/busybox.pod b/docs/busybox.pod index 4264f57c6..d42985306 100644 --- a/docs/busybox.pod +++ b/docs/busybox.pod | |||
@@ -61,7 +61,7 @@ fdflush, find, free, freeramdisk, fsck.minix, grep, gunzip, gzip, halt, | |||
61 | head, hostid, hostname, id, init, insmod, kill, killall, length, ln, | 61 | head, hostid, hostname, id, init, insmod, kill, killall, length, ln, |
62 | loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir, | 62 | loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir, |
63 | mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, | 63 | mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, |
64 | nslookup, ping, poweroff, printf, ps, pwd, reboot, rm, rmdir, rmmod, sed, | 64 | nslookup, ping, poweroff, printf, ps, pwd, reboot, renice, rm, rmdir, rmmod, sed, |
65 | setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail, | 65 | setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail, |
66 | tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, update, | 66 | tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, update, |
67 | uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, zcat, [ | 67 | uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, zcat, [ |
@@ -1386,6 +1386,16 @@ Instructs the kernel to reboot the system. | |||
1386 | 1386 | ||
1387 | ------------------------------- | 1387 | ------------------------------- |
1388 | 1388 | ||
1389 | =item renice | ||
1390 | |||
1391 | Usage: renice priority pid [pid ...] | ||
1392 | |||
1393 | Changes priority of running processes. Allowed priorities range | ||
1394 | from 20 (the process runs only when nothing else is running) to 0 | ||
1395 | (default priority) to -20 (almost nothing else ever gets to run). | ||
1396 | |||
1397 | ------------------------------- | ||
1398 | |||
1389 | =item rm | 1399 | =item rm |
1390 | 1400 | ||
1391 | Usage: rm [OPTION]... FILE... | 1401 | Usage: rm [OPTION]... FILE... |
@@ -2034,4 +2044,4 @@ Enrique Zanardi <ezanardi@ull.es> | |||
2034 | 2044 | ||
2035 | =cut | 2045 | =cut |
2036 | 2046 | ||
2037 | # $Id: busybox.pod,v 1.58 2000/07/21 15:10:57 proski Exp $ | 2047 | # $Id: busybox.pod,v 1.59 2000/07/21 21:32:12 andersen Exp $ |
diff --git a/docs/busybox.sgml b/docs/busybox.sgml index d19ee242c..f65abda69 100644 --- a/docs/busybox.sgml +++ b/docs/busybox.sgml | |||
@@ -140,7 +140,7 @@ | |||
140 | loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, | 140 | loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, |
141 | makedevs, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, | 141 | makedevs, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, |
142 | more, mount, mt, mv, nc, nslookup, ping, poweroff, printf, ps, | 142 | more, mount, mt, mv, nc, nslookup, ping, poweroff, printf, ps, |
143 | pwd, reboot, rm, rmdir, rmmod, sed, setkeycodes, sh, sleep, | 143 | pwd, reboot, renice, rm, rmdir, rmmod, sed, setkeycodes, sh, sleep, |
144 | sort, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, | 144 | sort, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, |
145 | test, touch, tr, true, tty, umount, uname, uniq, update, | 145 | test, touch, tr, true, tty, umount, uname, uniq, update, |
146 | uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, | 146 | uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, |
@@ -2445,6 +2445,20 @@ | |||
2445 | </para> | 2445 | </para> |
2446 | </sect1> | 2446 | </sect1> |
2447 | 2447 | ||
2448 | <sect1 id="renice"> | ||
2449 | <title>renice</title> | ||
2450 | |||
2451 | <para> | ||
2452 | Usage: renice priority pid [pid ...] | ||
2453 | </para> | ||
2454 | |||
2455 | <para> | ||
2456 | Changes priority of running processes. Allowed priorities range | ||
2457 | from 20 (the process runs only when nothing else is running) to 0 | ||
2458 | (default priority) to -20 (almost nothing else ever gets to run). | ||
2459 | </para> | ||
2460 | </sect1> | ||
2461 | |||
2448 | <sect1 id="rm"> | 2462 | <sect1 id="rm"> |
2449 | <title>rm</title> | 2463 | <title>rm</title> |
2450 | 2464 | ||
diff --git a/internal.h b/internal.h index 4800d8512..7f0b77475 100644 --- a/internal.h +++ b/internal.h | |||
@@ -177,6 +177,7 @@ extern int printf_main(int argc, char** argv); | |||
177 | extern int ps_main(int argc, char** argv); | 177 | extern int ps_main(int argc, char** argv); |
178 | extern int pwd_main(int argc, char** argv); | 178 | extern int pwd_main(int argc, char** argv); |
179 | extern int reboot_main(int argc, char** argv); | 179 | extern int reboot_main(int argc, char** argv); |
180 | extern int renice_main(int argc, char** argv); | ||
180 | extern int rm_main(int argc, char** argv); | 181 | extern int rm_main(int argc, char** argv); |
181 | extern int rmdir_main(int argc, char **argv); | 182 | extern int rmdir_main(int argc, char **argv); |
182 | extern int rmmod_main(int argc, char** argv); | 183 | extern int rmmod_main(int argc, char** argv); |
@@ -281,6 +282,7 @@ extern const char printf_usage[]; | |||
281 | extern const char ps_usage[]; | 282 | extern const char ps_usage[]; |
282 | extern const char pwd_usage[]; | 283 | extern const char pwd_usage[]; |
283 | extern const char reboot_usage[]; | 284 | extern const char reboot_usage[]; |
285 | extern const char renice_usage[]; | ||
284 | extern const char rm_usage[]; | 286 | extern const char rm_usage[]; |
285 | extern const char rmdir_usage[]; | 287 | extern const char rmdir_usage[]; |
286 | extern const char rmmod_usage[]; | 288 | extern const char rmmod_usage[]; |
diff --git a/procps/renice.c b/procps/renice.c new file mode 100644 index 000000000..af7ce94ca --- /dev/null +++ b/procps/renice.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Mini renice implementation for busybox | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 2000 Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include "internal.h" | ||
24 | #include <stdio.h> | ||
25 | #include <errno.h> | ||
26 | #include <sys/time.h> | ||
27 | #include <sys/resource.h> | ||
28 | |||
29 | |||
30 | extern int renice_main(int argc, char **argv) | ||
31 | { | ||
32 | int prio, err = 0; | ||
33 | |||
34 | if (argc < 3) usage(renice_usage); | ||
35 | |||
36 | prio = atoi(*++argv); | ||
37 | if (prio > 20) prio = 20; | ||
38 | if (prio < -20) prio = -20; | ||
39 | |||
40 | while (*++argv) { | ||
41 | int ps = atoi(*argv); | ||
42 | int oldp = getpriority(PRIO_PROCESS, ps); | ||
43 | |||
44 | if (setpriority(PRIO_PROCESS, ps, prio) == 0) { | ||
45 | printf("%d: old priority %d, new priority %d\n", ps, oldp, prio ); | ||
46 | } else { | ||
47 | fprintf(stderr, "renice: %d: setpriority: ", ps); | ||
48 | perror(""); | ||
49 | err = 1; | ||
50 | } | ||
51 | } | ||
52 | exit(err); | ||
53 | } | ||
diff --git a/renice.c b/renice.c new file mode 100644 index 000000000..af7ce94ca --- /dev/null +++ b/renice.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Mini renice implementation for busybox | ||
3 | * | ||
4 | * | ||
5 | * Copyright (C) 2000 Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include "internal.h" | ||
24 | #include <stdio.h> | ||
25 | #include <errno.h> | ||
26 | #include <sys/time.h> | ||
27 | #include <sys/resource.h> | ||
28 | |||
29 | |||
30 | extern int renice_main(int argc, char **argv) | ||
31 | { | ||
32 | int prio, err = 0; | ||
33 | |||
34 | if (argc < 3) usage(renice_usage); | ||
35 | |||
36 | prio = atoi(*++argv); | ||
37 | if (prio > 20) prio = 20; | ||
38 | if (prio < -20) prio = -20; | ||
39 | |||
40 | while (*++argv) { | ||
41 | int ps = atoi(*argv); | ||
42 | int oldp = getpriority(PRIO_PROCESS, ps); | ||
43 | |||
44 | if (setpriority(PRIO_PROCESS, ps, prio) == 0) { | ||
45 | printf("%d: old priority %d, new priority %d\n", ps, oldp, prio ); | ||
46 | } else { | ||
47 | fprintf(stderr, "renice: %d: setpriority: ", ps); | ||
48 | perror(""); | ||
49 | err = 1; | ||
50 | } | ||
51 | } | ||
52 | exit(err); | ||
53 | } | ||
@@ -859,6 +859,18 @@ const char reboot_usage[] = | |||
859 | ; | 859 | ; |
860 | #endif | 860 | #endif |
861 | 861 | ||
862 | |||
863 | #if defined BB_RENICE | ||
864 | const char renice_usage[] = | ||
865 | "renice priority pid [pid ...]\n" | ||
866 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
867 | "\nChanges priority of running processes. Allowed priorities range\n" | ||
868 | "from 20 (the process runs only when nothing else is running) to 0\n" | ||
869 | "(default priority) to -20 (almost nothing else ever gets to run).\n" | ||
870 | #endif | ||
871 | ; | ||
872 | #endif | ||
873 | |||
862 | #if defined BB_RM | 874 | #if defined BB_RM |
863 | const char rm_usage[] = | 875 | const char rm_usage[] = |
864 | "rm [OPTION]... FILE...\n" | 876 | "rm [OPTION]... FILE...\n" |