if (!PyArg_ParseTuple(args, "i:nice", &increment))
return NULL;
+
+ /* There are two flavours of 'nice': one that returns the new
+ priority (as required by almost all standards out there) and the
+ Linux one, which returns '0' on success and advices the use of
+ getpriority() to get the new priority.
+
+ If we are of the nice family that returns the new priority, we
+ need to clear errno before the call, and check if errno is filled
+ before calling posix_error() on a returnvalue of -1, because the
+ -1 may be the actual new priority! */
+
+ errno = 0;
value = nice(increment);
- if (value == -1)
+#ifdef HAVE_GETPRIORITY
+ if (value == 0)
+ value = getpriority(PRIO_PROCESS, 0);
+#endif
+ if (value == -1 && errno != 0)
+ /* either nice() or getpriority() returned an error */
return posix_error();
return PyInt_FromLong((long) value);
}
/* Define if you have the getpid function. */
#undef HAVE_GETPID
+/* Define if you have the getpriority function. */
+#undef HAVE_GETPRIORITY
+
/* Define if you have the getpwent function. */
#undef HAVE_GETPWENT
#! /bin/sh
-# From configure.in Revision: 1.215.2.1
+# From configure.in Revision: 1.215.2.2
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
setlocale setregid setreuid setsid setpgid setuid setvbuf \
sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
- truncate uname waitpid _getpty
+ truncate uname waitpid _getpty getpriority
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:4254: checking for $ac_func" >&5
setlocale setregid setreuid setsid setpgid setuid setvbuf \
sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
- truncate uname waitpid _getpty)
+ truncate uname waitpid _getpty getpriority)
# check for openpty and forkpty