4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
27 * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
31 #pragma ident "%Z%%M% %I% %E% SMI"
46 static void usage(void);
49 main(int argc
, char *argv
[])
53 (void) setlocale(LC_ALL
, "");
54 #if !defined(TEXT_DOMAIN)
55 #define TEXT_DOMAIN "SYS_TEST"
57 (void) textdomain(TEXT_DOMAIN
);
64 if (argv
[1][0] == '-') {
65 if (strcmp(argv
[1], "--") == 0) {
69 register char *p
= argv
[1];
73 if (*++p
== 'n') { /* -n55 new form, XCU4 */
75 * for situations like -n-10
76 * else case assigns p instead of argv
79 /* Next arg is priority */
86 /* Priority embedded eg. -n-10 */
89 } else { /* -55 obs form, XCU4 */
90 nicarg_str
= &argv
[1][1];
92 nicarg
= strtol(nicarg_str
, &end_ptr
, 10);
94 (void) fprintf(stderr
,
95 gettext("nice: argument must be numeric.\n"));
103 if (strcmp(argv
[1], "--") == 0) {
114 if (nice(nicarg
) == -1) {
116 * Could be an error or a legitimate return value.
117 * The only error we care about is EINVAL, which will
118 * be returned by the scheduling class we are in if
119 * nice is invalid for this class.
120 * For any error other than EINVAL
121 * we will go ahead and exec the command even though
122 * the priority change failed.
124 if (errno
== EINVAL
) {
125 (void) fprintf(stderr
, gettext(
126 "nice: invalid operation; "
127 "scheduling class does not support nice\n"));
131 (void) execvp(argv
[1], &argv
[1]);
132 (void) fprintf(stderr
, gettext("%s: %s\n"), strerror(errno
), argv
[1]);
134 * POSIX.2 exit status:
135 * 127 if utility is not found.
136 * 126 if utility cannot be invoked.
138 return (errno
== ENOENT
|| errno
== ENOTDIR
? 127 : 126);
144 (void) fprintf(stderr
,
145 gettext("nice: usage: nice [-n increment] utility [argument ...]\n"));