rationalized handling of child processes, cleaned up mail1 some more
[unix-history] / usr / src / usr.bin / nice / nice.c
CommitLineData
bcf1365c
DF
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
8char copyright[] =
9"@(#) Copyright (c) 1980 Regents of the University of California.\n\
10 All rights reserved.\n";
11#endif not lint
12
a8df6a6b 13#ifndef lint
a1844d11 14static char sccsid[] = "@(#)nice.c 5.2 (Berkeley) %G%";
bcf1365c 15#endif not lint
a0641931
BJ
16
17#include <stdio.h>
18
a8df6a6b
SL
19#include <sys/time.h>
20#include <sys/resource.h>
21
a0641931 22main(argc, argv)
a8df6a6b
SL
23 int argc;
24 char *argv[];
a0641931
BJ
25{
26 int nicarg = 10;
a0641931 27
a8df6a6b 28 if (argc > 1 && argv[1][0] == '-') {
a0641931 29 nicarg = atoi(&argv[1][1]);
a8df6a6b 30 argc--, argv++;
a0641931 31 }
a8df6a6b 32 if (argc < 2) {
a0641931
BJ
33 fputs("usage: nice [ -n ] command\n", stderr);
34 exit(1);
35 }
a1844d11
JL
36 if (setpriority(PRIO_PROCESS, 0,
37 getpriority(PRIO_PROCESS, 0) + nicarg) < 0) {
a8df6a6b
SL
38 perror("setpriority");
39 exit(1);
40 }
a0641931 41 execvp(argv[1], &argv[1]);
a8df6a6b 42 perror(argv[1]);
a0641931
BJ
43 exit(1);
44}