]> Zhao Yanbai Git Server - minix.git/commitdiff
Nice(3) implementation
authorPhilip Homburg <philip@cs.vu.nl>
Fri, 20 Oct 2006 14:10:53 +0000 (14:10 +0000)
committerPhilip Homburg <philip@cs.vu.nl>
Fri, 20 Oct 2006 14:10:53 +0000 (14:10 +0000)
include/unistd.h
lib/posix/Makefile.in
lib/posix/nice.c [new file with mode: 0644]

index 0d6f780b513d57fa1bc4ba03917385907a0f02c2..2b1baafd78609a823db8202bd064915deabf2d3b 100755 (executable)
@@ -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)                );
index 7d6abc211e059da179647c8bba214724552551cf..b3eec7cc5bd00a28b71e0345330a904e408be4ff 100644 (file)
@@ -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 (file)
index 0000000..4f750f9
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+nice.c
+*/
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/resource.h>
+
+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);
+}