From be928f01a564899f87ca237db6dc125557de90fa Mon Sep 17 00:00:00 2001 From: Philip Homburg Date: Fri, 20 Oct 2006 14:10:53 +0000 Subject: [PATCH] Nice(3) implementation --- include/unistd.h | 1 + lib/posix/Makefile.in | 1 + lib/posix/nice.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 lib/posix/nice.c diff --git a/include/unistd.h b/include/unistd.h index 0d6f780b5..2b1baafd7 100755 --- a/include/unistd.h +++ b/include/unistd.h @@ -146,6 +146,7 @@ _PROTOTYPE( int unlink, (const char *_path) ); _PROTOTYPE( ssize_t write, (int _fd, const void *_buf, size_t _n) ); _PROTOTYPE( int truncate, (const char *_path, off_t _length) ); _PROTOTYPE( int ftruncate, (int _fd, off_t _length) ); +_PROTOTYPE( int nice, (int _incr) ); /* Open Group Base Specifications Issue 6 (not complete) */ _PROTOTYPE( int symlink, (const char *path1, const char *path2) ); diff --git a/lib/posix/Makefile.in b/lib/posix/Makefile.in index 7d6abc211..b3eec7cc5 100644 --- a/lib/posix/Makefile.in +++ b/lib/posix/Makefile.in @@ -102,6 +102,7 @@ libc_FILES=" \ getloadavg.c \ getopt.c \ gettimeofday.c \ + nice.c \ priority.c \ usleep.c" diff --git a/lib/posix/nice.c b/lib/posix/nice.c new file mode 100644 index 000000000..4f750f926 --- /dev/null +++ b/lib/posix/nice.c @@ -0,0 +1,19 @@ +/* +nice.c +*/ + +#include +#include +#include + +int nice(incr) +int incr; +{ + int r; + + errno= 0; + r= getpriority(PRIO_PROCESS, 0); + if (r == -1 && errno != 0) + return r; + return setpriority(PRIO_PROCESS, 0, r+incr); +}