From owner-freebsd-bugs Sun Jan 20 0:10: 8 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A033237B402 for ; Sun, 20 Jan 2002 00:10:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g0K8A1p74535; Sun, 20 Jan 2002 00:10:01 -0800 (PST) (envelope-from gnats) Received: from HAL9000.wox.org (12-232-222-90.client.attbi.com [12.232.222.90]) by hub.freebsd.org (Postfix) with ESMTP id 8D34137B416 for ; Sun, 20 Jan 2002 00:03:04 -0800 (PST) Received: (from dschultz@localhost) by HAL9000.wox.org (8.11.3/8.11.3) id g0K84wp01924; Sun, 20 Jan 2002 00:04:58 -0800 (PST) (envelope-from dschultz) Message-Id: <200201200804.g0K84wp01924@HAL9000.wox.org> Date: Sun, 20 Jan 2002 00:04:58 -0800 (PST) From: dschultz@uclink.Berkeley.EDU To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/34076: [PATCH] Add -n flag to renice; update docs Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 34076 >Category: bin >Synopsis: [PATCH] Add -n flag to renice; update docs >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jan 20 00:10:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: David Schultz >Release: FreeBSD 4.3-RELEASE i386 >Organization: cluttered >Environment: System: FreeBSD HAL9000.wox.org 4.3-RELEASE FreeBSD 4.3-RELEASE #6: Sun Jan 13 02:46:53 PST 2002 dschultz@HAL9000.wox.org:/usr/obj/usr/src/sys/HAL9000 i386 >Description: Add the -n flag to renice, which allows priorities to be specified as an offset of a process' current priority. >How-To-Repeat: >Fix: --- renice.c.orig Sat Jan 19 22:37:21 2002 +++ renice.c Sat Jan 19 22:51:56 2002 @@ -56,7 +56,10 @@ #include #include -int donice __P((int, int, int)); +#define CHANGE_ABS 1 +#define CHANGE_REL 2 + +int donice __P((int, int, int, int)); static void usage __P((void)); /* @@ -70,17 +73,19 @@ char **argv; { int which = PRIO_PROCESS; - int who = 0, prio, errs = 0; + int who = 0, prio, errs = 0, change = CHANGE_ABS; argc--, argv++; if (argc < 2) usage(); + if (strcmp(*argv, "-n") == 0) { + change = CHANGE_REL; + argc--, argv++; + if (argc < 2) + usage(); + } prio = atoi(*argv); argc--, argv++; - if (prio > PRIO_MAX) - prio = PRIO_MAX; - if (prio < PRIO_MIN) - prio = PRIO_MIN; for (; argc > 0; argc--, argv++) { if (strcmp(*argv, "-g") == 0) { which = PRIO_PGRP; @@ -109,7 +114,7 @@ continue; } } - errs += donice(which, who, prio); + errs += donice(which, who, prio, change); } exit(errs != 0); } @@ -118,13 +123,13 @@ usage() { fprintf(stderr, -"usage: renice priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]\n"); +"usage: renice [ -n ] priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]\n"); exit(1); } int -donice(which, who, prio) - int which, who, prio; +donice(which, who, prio, change) + int which, who, prio, change; { int oldprio; @@ -133,6 +138,12 @@ warn("%d: getpriority", who); return (1); } + if (change == CHANGE_REL) + prio += oldprio; + if (prio > PRIO_MAX) + prio = PRIO_MAX; + if (prio < PRIO_MIN) + prio = PRIO_MIN; if (setpriority(which, who, prio) < 0) { warn("%d: setpriority", who); return (1); --- renice.8.orig Sat Jan 19 22:37:29 2002 +++ renice.8 Sat Jan 19 23:30:39 2002 @@ -40,6 +40,7 @@ .Nd alter priority of running processes .Sh SYNOPSIS .Nm +.Op Fl n .Ar priority .Oo .Op Fl p @@ -73,6 +74,10 @@ Options supported by .Nm : .Bl -tag -width Ds +.It Fl n +Interpret the +.Ar priority +parameter as an offset from the process' current priority. .It Fl g Force .Ar who @@ -87,14 +92,6 @@ interpretation to be (the default) process ID's. .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'' @@ -114,6 +111,21 @@ in the system wants to), 0 (the ``base'' scheduling priority), anything negative (to make things go very fast). +.Sh EXAMPLES +.Pp +.Bd -literal -offset indent +renice +1 987 -u daemon root -p 32 +.Ed +.Pp +Change the priority of process ID's 987 and 32, and +all processes owned by users daemon and root. +.Pp +.Bd -literal -offset indent +renice -n -5 654 +.Ed +.Pp +Decrease the ``nice value'' of process ID 654 by 5, +assuming you are a super-user. .Sh FILES .Bl -tag -width /etc/passwd -compact .It Pa /etc/passwd >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message