diff options
-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 @@ 0.47pre + * added 'renice' command -- thanks to Dave Cinege <dcinege@psychosis.com> * 'make install' now creates relative symlinks, and added a new 'make install-hardlinks' target to (tada) install hardlinks. * 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[] = { #ifdef BB_REBOOT {"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage}, #endif +#ifdef BB_RENICE + {"renice", renice_main, _BB_DIR_USR_BIN}, +#endif #ifdef BB_RM {"rm", rm_main, _BB_DIR_BIN, rm_usage}, #endif @@ -484,8 +487,9 @@ int main(int argc, char **argv) #ifdef BB_SH /* Add in a special case hack -- whenever **argv == '-' * (i.e. '-su' or '-sh') always invoke the shell */ - if (**argv == '-') + if (**argv == '-' && *(*argv+1)!= '-') { exit(((*(shell_main)) (argc, argv))); + } #endif 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[] = ; #endif + +#if defined BB_RENICE +const char renice_usage[] = + "renice priority pid [pid ...]\n" +#ifndef BB_FEATURE_TRIVIAL_HELP + "\nChanges priority of running processes. Allowed priorities range\n" + "from 20 (the process runs only when nothing else is running) to 0\n" + "(default priority) to -20 (almost nothing else ever gets to run).\n" +#endif + ; +#endif + #if defined BB_RM const char rm_usage[] = "rm [OPTION]... FILE...\n" @@ -250,6 +250,9 @@ const struct BB_applet applets[] = { #ifdef BB_REBOOT {"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage}, #endif +#ifdef BB_RENICE + {"renice", renice_main, _BB_DIR_USR_BIN}, +#endif #ifdef BB_RM {"rm", rm_main, _BB_DIR_BIN, rm_usage}, #endif @@ -484,8 +487,9 @@ int main(int argc, char **argv) #ifdef BB_SH /* Add in a special case hack -- whenever **argv == '-' * (i.e. '-su' or '-sh') always invoke the shell */ - if (**argv == '-') + if (**argv == '-' && *(*argv+1)!= '-') { exit(((*(shell_main)) (argc, argv))); + } #endif 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 @@ #define BB_PS #define BB_PWD #define BB_REBOOT +#define BB_RENICE #define BB_RM #define BB_RMDIR #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, head, hostid, hostname, id, init, insmod, kill, killall, length, ln, loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, -nslookup, ping, poweroff, printf, ps, pwd, reboot, rm, rmdir, rmmod, sed, +nslookup, ping, poweroff, printf, ps, pwd, reboot, renice, rm, rmdir, rmmod, sed, setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, update, uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, zcat, [ @@ -1386,6 +1386,16 @@ Instructs the kernel to reboot the system. ------------------------------- +=item renice + +Usage: renice priority pid [pid ...] + +Changes priority of running processes. Allowed priorities range +from 20 (the process runs only when nothing else is running) to 0 +(default priority) to -20 (almost nothing else ever gets to run). + +------------------------------- + =item rm Usage: rm [OPTION]... FILE... @@ -2034,4 +2044,4 @@ Enrique Zanardi <ezanardi@ull.es> =cut -# $Id: busybox.pod,v 1.58 2000/07/21 15:10:57 proski Exp $ +# $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 @@ loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, nslookup, ping, poweroff, printf, ps, - pwd, reboot, rm, rmdir, rmmod, sed, setkeycodes, sh, sleep, + pwd, reboot, renice, rm, rmdir, rmmod, sed, setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail, tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, update, uptime, usleep, uudecode, uuencode, wc, which, whoami, yes, @@ -2445,6 +2445,20 @@ </para> </sect1> + <sect1 id="renice"> + <title>renice</title> + + <para> + Usage: renice priority pid [pid ...] + </para> + + <para> + Changes priority of running processes. Allowed priorities range + from 20 (the process runs only when nothing else is running) to 0 + (default priority) to -20 (almost nothing else ever gets to run). + </para> + </sect1> + <sect1 id="rm"> <title>rm</title> 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); extern int ps_main(int argc, char** argv); extern int pwd_main(int argc, char** argv); extern int reboot_main(int argc, char** argv); +extern int renice_main(int argc, char** argv); extern int rm_main(int argc, char** argv); extern int rmdir_main(int argc, char **argv); extern int rmmod_main(int argc, char** argv); @@ -281,6 +282,7 @@ extern const char printf_usage[]; extern const char ps_usage[]; extern const char pwd_usage[]; extern const char reboot_usage[]; +extern const char renice_usage[]; extern const char rm_usage[]; extern const char rmdir_usage[]; 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 @@ +/* + * Mini renice implementation for busybox + * + * + * Copyright (C) 2000 Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "internal.h" +#include <stdio.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/resource.h> + + +extern int renice_main(int argc, char **argv) +{ + int prio, err = 0; + + if (argc < 3) usage(renice_usage); + + prio = atoi(*++argv); + if (prio > 20) prio = 20; + if (prio < -20) prio = -20; + + while (*++argv) { + int ps = atoi(*argv); + int oldp = getpriority(PRIO_PROCESS, ps); + + if (setpriority(PRIO_PROCESS, ps, prio) == 0) { + printf("%d: old priority %d, new priority %d\n", ps, oldp, prio ); + } else { + fprintf(stderr, "renice: %d: setpriority: ", ps); + perror(""); + err = 1; + } + } + exit(err); +} diff --git a/renice.c b/renice.c new file mode 100644 index 000000000..af7ce94ca --- /dev/null +++ b/renice.c @@ -0,0 +1,53 @@ +/* + * Mini renice implementation for busybox + * + * + * Copyright (C) 2000 Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "internal.h" +#include <stdio.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/resource.h> + + +extern int renice_main(int argc, char **argv) +{ + int prio, err = 0; + + if (argc < 3) usage(renice_usage); + + prio = atoi(*++argv); + if (prio > 20) prio = 20; + if (prio < -20) prio = -20; + + while (*++argv) { + int ps = atoi(*argv); + int oldp = getpriority(PRIO_PROCESS, ps); + + if (setpriority(PRIO_PROCESS, ps, prio) == 0) { + printf("%d: old priority %d, new priority %d\n", ps, oldp, prio ); + } else { + fprintf(stderr, "renice: %d: setpriority: ", ps); + perror(""); + err = 1; + } + } + exit(err); +} @@ -859,6 +859,18 @@ const char reboot_usage[] = ; #endif + +#if defined BB_RENICE +const char renice_usage[] = + "renice priority pid [pid ...]\n" +#ifndef BB_FEATURE_TRIVIAL_HELP + "\nChanges priority of running processes. Allowed priorities range\n" + "from 20 (the process runs only when nothing else is running) to 0\n" + "(default priority) to -20 (almost nothing else ever gets to run).\n" +#endif + ; +#endif + #if defined BB_RM const char rm_usage[] = "rm [OPTION]... FILE...\n" |