Nice(3) implementation
This commit is contained in:
parent
0b2c167c48
commit
be928f01a5
|
@ -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) );
|
||||
|
|
|
@ -102,6 +102,7 @@ libc_FILES=" \
|
|||
getloadavg.c \
|
||||
getopt.c \
|
||||
gettimeofday.c \
|
||||
nice.c \
|
||||
priority.c \
|
||||
usleep.c"
|
||||
|
||||
|
|
19
lib/posix/nice.c
Normal file
19
lib/posix/nice.c
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue