Added 'renice' command, thanks to Dave Cinege <dcinege@psychosis.com>

-Erik
This commit is contained in:
Eric Andersen 2000-07-21 21:32:12 +00:00
parent 7df345e149
commit bf960f58e2
11 changed files with 171 additions and 5 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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"

View File

@ -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) {

View File

@ -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

View File

@ -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 $

View File

@ -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>

View File

@ -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[];

53
procps/renice.c Normal file
View File

@ -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);
}

53
renice.c Normal file
View File

@ -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);
}

12
usage.c
View File

@ -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"