1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 */ 6 7 #ifndef lint 8 char copyright[] = 9 "@(#) Copyright (c) 1980 Regents of the University of California.\n\ 10 All rights reserved.\n"; 11 #endif not lint 12 13 #ifndef lint 14 static char sccsid[] = "@(#)nice.c 5.1 (Berkeley) 04/30/85"; 15 #endif not lint 16 17 #include <stdio.h> 18 19 #include <sys/time.h> 20 #include <sys/resource.h> 21 22 main(argc, argv) 23 int argc; 24 char *argv[]; 25 { 26 int nicarg = 10; 27 28 if (argc > 1 && argv[1][0] == '-') { 29 nicarg = atoi(&argv[1][1]); 30 argc--, argv++; 31 } 32 if (argc < 2) { 33 fputs("usage: nice [ -n ] command\n", stderr); 34 exit(1); 35 } 36 if (setpriority(PRIO_PROCESS, 0, nicarg) < 0) { 37 perror("setpriority"); 38 exit(1); 39 } 40 execvp(argv[1], &argv[1]); 41 perror(argv[1]); 42 exit(1); 43 } 44