xref: /csrg-svn/usr.bin/nice/nice.c (revision 12669)
1*12669Ssam #ifndef lint
2*12669Ssam static char *sccsid = "@(#)nice.c	4.2 (Berkeley) 05/22/83";
3*12669Ssam #endif
41059Sbill 
51059Sbill #include <stdio.h>
61059Sbill 
7*12669Ssam #include <sys/time.h>
8*12669Ssam #include <sys/resource.h>
9*12669Ssam 
101059Sbill main(argc, argv)
11*12669Ssam 	int argc;
12*12669Ssam 	char *argv[];
131059Sbill {
141059Sbill 	int nicarg = 10;
151059Sbill 
16*12669Ssam 	if (argc > 1 && argv[1][0] == '-') {
171059Sbill 		nicarg = atoi(&argv[1][1]);
18*12669Ssam 		argc--, argv++;
191059Sbill 	}
20*12669Ssam 	if (argc < 2) {
211059Sbill 		fputs("usage: nice [ -n ] command\n", stderr);
221059Sbill 		exit(1);
231059Sbill 	}
24*12669Ssam 	if (setpriority(PRIO_PROCESS, 0, nicarg) < 0) {
25*12669Ssam 		perror("setpriority");
26*12669Ssam 		exit(1);
27*12669Ssam 	}
281059Sbill 	execvp(argv[1], &argv[1]);
29*12669Ssam 	perror(argv[1]);
301059Sbill 	exit(1);
311059Sbill }
32