From 534e9a5d77adbcfe09d4ad6c643ea7bf3c824449 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 14 Mar 2019 13:11:44 -0400 Subject: first cut --- nice.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 nice.c diff --git a/nice.c b/nice.c new file mode 100644 index 0000000..274191d --- /dev/null +++ b/nice.c @@ -0,0 +1,34 @@ +#define _XOPEN_SOURCE 700 +#include +#include +#include +#include + +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; +} -- cgit v1.2.1