diff options
Diffstat (limited to 'nice.c')
| -rw-r--r-- | nice.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -0,0 +1,34 @@ +#define _XOPEN_SOURCE 700 +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int main(int argc, char *argv[]) +{ + int increment = 0; + int c; + + while ((c = getopt(argc, argv, "n:")) != -1) { + switch (c) { + case 'n': + increment = atoi(optarg); + break; + + default: + return 1; + } + } + + argv += optind; + + errno = 0; + if (nice(increment) == -1 && errno != 0) { + perror("nice"); + } + + execvp(argv[0], argv); + + perror("nice"); + return errno == ENOENT ? 127 : 126; +} |
