sbase/nice.c

39 lines
612 B
C
Raw Normal View History

2013-06-09 09:20:55 -04:00
/* See LICENSE file for copyright and license details. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "util.h"
static void
usage(void)
{
eprintf("usage: nice [-n inc] command [options ...]\n");
}
int
main(int argc, char **argv)
{
int inc = 10;
ARGBEGIN {
case 'n':
inc = atoi(EARGF(usage()));
break;
default:
usage();
} ARGEND;
nice(inc); /* POSIX specifies the nice failure still invokes the command. */
if(!*argv)
usage();
execvp(*argv, argv);
eprintf("nice: '%s': %s\n", *argv, strerror(errno));
return EXIT_FAILURE;
}