4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
31 #include <sys/param.h>
32 #include <sys/priocntl.h>
33 #include <sys/types.h>
38 "usage: priocntl -l\n\
39 priocntl -d [-i idtype] [idlist]\n";
42 * A whole lot of to-do for a scheduling class that can't actually be
43 * configured or used by user processes.
46 main(int argc
, char *argv
[])
48 int dflag
, eflag
, iflag
, lflag
, sflag
;
50 char cmdpath
[MAXPATHLEN
];
51 char basenm
[BASENMSZ
];
53 (void) strlcpy(cmdpath
, argv
[0], MAXPATHLEN
);
54 (void) strlcpy(basenm
, basename(argv
[0]), BASENMSZ
);
56 dflag
= eflag
= iflag
= lflag
= sflag
= 0;
57 while ((c
= getopt(argc
, argv
, "c:dei:ls")) != -1) {
61 if (strcmp(optarg
, "SDC") != 0)
62 fatalerr("error: %s executed for %s class, "
63 "%s is actually sub-command for %s class\n",
64 cmdpath
, optarg
, cmdpath
, "SDC");
76 iflag
++; /* optarg is parsed, but ignored */
101 "priocntl: \"-%c\" may not be used with the %s class\n",
102 (sflag
? 's' : 'e'), "SDC");
105 if ((!dflag
&& !lflag
) || (dflag
&& lflag
)) {
114 * No scheduling-class-specific information to print,
115 * but we read the pidlist to avoid generating a SIGPIPE
116 * in the main priocntl process. Once we've read it,
117 * we might as well print it.
119 if ((pidlist
= read_pidlist(&numread
, stdin
)) == NULL
) {
120 fatalerr("%s: Can't read pidlist.\n", basenm
);
121 } else if (numread
== 0) {
122 fatalerr("%s: No pids on input.\n", basenm
);
124 (void) printf("SYSTEM DUTY-CYCLE PROCESSES:\n");
125 (void) printf("%7s\n", "PID");
126 for (i
= 0; i
< numread
; i
++) {
127 (void) printf("%7ld\n", pidlist
[i
]);
130 free_pidlist(pidlist
);
132 (void) printf("SDC (System Duty-Cycle Class)\n");