From owner-freebsd-standards Wed Apr 10 0:40:10 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 4080237B417 for ; Wed, 10 Apr 2002 00:40:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3A7e3590514; Wed, 10 Apr 2002 00:40:03 -0700 (PDT) (envelope-from gnats) Date: Wed, 10 Apr 2002 00:40:03 -0700 (PDT) Message-Id: <200204100740.g3A7e3590514@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36950: Add -n to renice(8) Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36950; it has been noted by GNATS. From: "Tim J. Robbins" To: Peter Avalos Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: standards/36950: Add -n to renice(8) Date: Wed, 10 Apr 2002 17:10:37 +1000 On Wed, Apr 10, 2002 at 04:16:02AM -0000, Peter Avalos wrote: > >Number: 36950 > >Category: standards > >Synopsis: Add -n to renice(8) > Index: renice.8 > =================================================================== > +.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. The comment about historical behaviour probably belongs in a COMPATIBILITY section. > Index: renice.c > =================================================================== > -static const char copyright[] = > +static char copyright[] = I believe this should stay const. You could consider using the __COPYRIGHT macro, but \n's in its argument don't work properly. > + prio = strtol(*argv, &endptr, 10); > + if (*endptr || Should check whether endptr == *argv. renice '' should not be allowed. > + ((prio == LONG_MAX || prio == LONG_MIN) && errno == ERANGE)) > + errx(EX_DATAERR, "Invalid input: %s", *argv); prio is an int so might not ever be able to take value LONG_{MIN,MAX}. -n should be accepted with its argument joined to it, for example -n4 as well as -n 4. Solaris accepts this and the standard specifies it. NetBSD has got it wrong. > + /* > + * 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++; > + Handling these in the loop is the traditional BSD, and SUSv2 behaviour. Worth noting in the COMPATIBILITY section of the manual page that this syntax isn't allowed anymore if you choose to remove it. > + /* If argv is not a number, then we should be PRIO_USER. */ No, non-numeric arguments are invalid unless preceeded by -u. > - exit(errs != 0); > + exit(errs); Existing code was better; knowing how many requests failed is not useful, and it could wrap back around to 0 (success) or other strange things. > - 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); This should just be removed alltogether - SUSv3 specifies that standard output is not used at all, despite this being traditional behaviour. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message