FreeBSD Bugzilla – Attachment 21022 Details for
Bug 36950
Add -n to renice(8)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 8.10 KB, created by
Peter Avalos
on 2002-04-10 05:20:02 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Peter Avalos
Created:
2002-04-10 05:20:02 UTC
Size:
8.10 KB
patch
obsolete
>Index: renice.8 >=================================================================== >RCS file: /cvsroot/fbsd/src/usr.bin/renice/renice.8,v >retrieving revision 1.9 >diff -u -r1.9 renice.8 >--- renice.8 5 Aug 2001 22:07:27 -0000 1.9 >+++ renice.8 7 Mar 2002 09:26:45 -0000 >@@ -40,90 +40,103 @@ > .Nd alter priority of running processes > .Sh SYNOPSIS > .Nm >-.Ar priority >+.Ar nice_value > .Oo >-.Op Fl p >-.Ar pid ... >+.Fl g | >+.Fl p >+| >+.Fl u > .Oc >+.Ar ID ... >+.Nm >+.Fl n Ar increment > .Oo >-.Op Fl g >-.Ar pgrp ... >-.Oc >-.Oo >-.Op Fl u >-.Ar user ... >+.Fl g | >+.Fl p >+| >+.Fl u > .Oc >+.Ar ID ... > .Sh DESCRIPTION > .Nm Renice > alters the > scheduling priority of one or more running processes. >-The following >-.Ar who >-parameters are interpreted as process ID's, process group >-ID's, or user names. >-.Nm Renice Ns 'ing >+By default, the processes to be affected are specified by >+their process ID's. >+Specifying > a process group causes all processes in the process group > to have their scheduling priority altered. >-.Nm Renice Ns 'ing >+Specifying > a user causes all processes owned by the user to have > their scheduling priority altered. >-By default, the processes to be affected are specified by >-their process ID's. >+.Pp >+If the requested priority or increment would exceed PRIO_MIN (\-20) >+or PRIO_MAX (20), the limit that was exceeded is used. >+Only the superuser may affect the scheduling priority of processes >+owned by another user. >+Only the superuser may increase the scheduling priority of a process >+(decrease the nice_value). > .Pp > Options supported by > .Nm : > .Bl -tag -width Ds >+.It Fl n Ar increment >+Increment the scheduling priority of the specified process. >+Positive values will decrease the scheduling priority, and negative >+values will increase the scheduling priority. >+Only the superuser may specify a negative value. > .It Fl g >-Force >-.Ar who >-parameters to be interpreted as process group ID's. >-.It Fl u >-Force the >-.Ar who >-parameters to be interpreted as user names. >+Interpret all >+.Ar ID >+arguments as unsigned decimal integer process group ID's. > .It Fl p >-Resets the >-.Ar who >-interpretation to be (the default) process ID's. >+Interpret all >+.Ar ID >+arguments as unsigned decimal integer process ID's. >+This is the default if no options are specified. >+.It Fl u >+Interpret all >+.Ar ID >+arguments as users. >+The >+.Ar ID >+may be a valid user name or an unsigned decimal integer user ID. > .El > .Pp >-For example, >-.Bd -literal -offset >-renice +1 987 -u daemon root -p 32 >-.Ed >-.Pp >-would change the priority of process ID's 987 and 32, and >-all processes owned by users daemon and root. >-.Pp >-Users other than the super-user may only alter the priority of >-processes they own, >-and can only monotonically increase their ``nice value'' >-within the range 0 to >-.Dv PRIO_MAX >-(20). >-(This prevents overriding administrative fiats.) >-The super-user >-may alter the priority of any process >-and set the priority to any value in the range >-.Dv PRIO_MIN >-(\-20) >-to >-.Dv PRIO_MAX . >-Useful priorities are: >+Useful nice_values are: > 20 (the affected processes will run only when nothing else > in the system wants to), > 0 (the ``base'' scheduling priority), > anything negative (to make things go very fast). >-.Sh FILES >-.Bl -tag -width /etc/passwd -compact >-.It Pa /etc/passwd >-to map user names to user ID's >-.El >+.Sh EXAMPLES >+Adjust the system scheduling priority so group >+ID's 69 and 77 have a lower priority: >+.Pp >+.Dl % renice -n 5 -g 69 77 >+.Pp >+Adjust the system scheduling priority so process >+ID's 2987 and 85723 have the lowest priority: >+.Pp >+.Dl % renice 20 2987 85723 >+.Pp >+Adjust the system scheduling priority so user >+foo and user ID 2000 have higher priority: >+.Pp >+.Dl # renice -n -5 -u foo 2000 >+.Pp > .Sh SEE ALSO > .Xr nice 1 , > .Xr rtprio 1 , > .Xr getpriority 2 , > .Xr setpriority 2 >+.Sh STANDARDS >+The >+.Nm >+utility conforms to >+.St -p1003.1-2001 >+Note: Specifying >+.Ar nice_value >+is deprecated, but it is accepted due to its historical significance. > .Sh BUGS > Non super-users cannot increase scheduling priorities of their own processes, > even if they were the ones that decreased the priorities in the first place. >Index: renice.c >=================================================================== >RCS file: /cvsroot/fbsd/src/usr.bin/renice/renice.c,v >retrieving revision 1.8 >diff -u -r1.8 renice.c >--- renice.c 22 Mar 2002 01:33:21 -0000 1.8 >+++ renice.c 10 Apr 2002 04:01:08 -0000 >@@ -32,18 +32,19 @@ > */ > > #ifndef lint >-static const char copyright[] = >+static char copyright[] = > "@(#) Copyright (c) 1983, 1989, 1993\n\ > The Regents of the University of California. All rights reserved.\n"; > #endif /* not lint */ > >-#ifndef lint > #if 0 >+#ifndef lint > static char sccsid[] = "@(#)renice.c 8.1 (Berkeley) 6/9/93"; >-#endif >-static const char rcsid[] = >- "$FreeBSD: src/usr.bin/renice/renice.c,v 1.8 2002/03/22 01:33:21 imp Exp $"; > #endif /* not lint */ >+#endif >+ >+#include <sys/cdefs.h> >+__FBSDID("$FreeBSD$"); > > #include <sys/types.h> > #include <sys/time.h> >@@ -51,12 +52,14 @@ > > #include <err.h> > #include <errno.h> >+#include <limits.h> >+#include <pwd.h> > #include <stdio.h> > #include <stdlib.h> > #include <string.h> >-#include <pwd.h> >+#include <sysexits.h> > >-int donice(int, int, int); >+static int donice(int, int, int, int); > static void usage(void); > > /* >@@ -65,66 +68,79 @@ > * running. > */ > int >-main(argc, argv) >- int argc; >- char **argv; >+main(int argc, char *argv[]) > { >- int which = PRIO_PROCESS; >- int who = 0, prio, errs = 0; >+ struct passwd *pwd; >+ char *endptr; >+ int errs, nflag, prio, which, who; >+ >+ which = PRIO_PROCESS; >+ errs = 0, nflag = 0, who = 0; > > argc--, argv++; > if (argc < 2) > usage(); >- prio = atoi(*argv); >+ >+ /* Parse priority or -n increment. */ >+ if (strcmp(*argv, "-n") == 0) { >+ nflag = 1; >+ argc--, argv++; >+ if (argc < 2) >+ usage(); >+ } >+ prio = strtol(*argv, &endptr, 10); >+ if (*endptr || >+ ((prio == LONG_MAX || prio == LONG_MIN) && errno == ERANGE)) >+ errx(EX_DATAERR, "Invalid input: %s", *argv); > argc--, argv++; >- if (prio > PRIO_MAX) >- prio = PRIO_MAX; >- if (prio < PRIO_MIN) >- prio = PRIO_MIN; >+ >+ /* >+ * Accept -g, -p, -u, or a number. If it's a number, default >+ * to -p (PRIO_PROCESS). >+ */ >+ if (strcmp(*argv, "-g") == 0) { >+ which = PRIO_PGRP; >+ argc--, argv++; >+ } else if (strcmp(*argv, "-u") == 0) { >+ which = PRIO_USER; >+ argc--, argv++; >+ } else if (strcmp(*argv, "-p") == 0) >+ argc--, argv++; >+ > for (; argc > 0; argc--, argv++) { >- if (strcmp(*argv, "-g") == 0) { >- which = PRIO_PGRP; >- continue; >- } >- if (strcmp(*argv, "-u") == 0) { >- which = PRIO_USER; >- continue; >- } >- if (strcmp(*argv, "-p") == 0) { >- which = PRIO_PROCESS; >+ who = strtoul(*argv, &endptr, 10); >+ >+ /* If argv is not a number, then we should be PRIO_USER. */ >+ if ((*endptr && which != PRIO_USER) || >+ ((who == LONG_MAX || who == LONG_MIN) && errno == ERANGE)) { >+ warnx("Invalid input: %s", *argv); > continue; > } >- if (which == PRIO_USER) { >- register struct passwd *pwd = getpwnam(*argv); >+ if (which == PRIO_USER && *endptr) { >+ pwd = getpwnam(*argv); > > if (pwd == NULL) { > warnx("%s: unknown user", *argv); > continue; > } > who = pwd->pw_uid; >- } else { >- who = atoi(*argv); >- if (who < 0) { >- warnx("%s: bad value", *argv); >- continue; >- } > } >- errs += donice(which, who, prio); >+ errs += donice(which, who, prio, nflag); > } >- exit(errs != 0); >+ exit(errs); > } > > static void >-usage() >+usage(void) > { >- fprintf(stderr, >-"usage: renice priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]\n"); >- exit(1); >+ >+ fprintf(stderr, "usage: renice nice_value [-g | -p | -u] ID ...\n"); >+ fprintf(stderr, " renice -n increment [-g | -p | -u] ID ...\n"); >+ exit(EX_USAGE); > } > >-int >-donice(which, who, prio) >- int which, who, prio; >+static int >+donice(int which, int who, int prio, int nflag) > { > int oldprio; > >@@ -133,10 +149,12 @@ > warn("%d: getpriority", who); > return (1); > } >+ if (nflag) >+ prio += oldprio; /* Possible over/underflow here. */ > if (setpriority(which, who, prio) < 0) { > warn("%d: setpriority", who); > return (1); > } >- printf("%d: old priority %d, new priority %d\n", who, oldprio, prio); >+ printf("%d: old nice_value %d, new nice_value %d\n", who, oldprio, prio); > return (0); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 36950
: 21022