summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2001-07-11 22:35:31 (GMT)
committerThomas Wouters <thomas@python.org>2001-07-11 22:35:31 (GMT)
commite38b2f1f00f46e24eaf83182799f4f515ffb410d (patch)
tree3318084926879333c95c7a3d032fa5646d4bba55 /Modules
parent3230d5c96111660f9b8c6f4fc0f86c545dd94df5 (diff)
downloadcpython-e38b2f1f00f46e24eaf83182799f4f515ffb410d.zip
cpython-e38b2f1f00f46e24eaf83182799f4f515ffb410d.tar.gz
cpython-e38b2f1f00f46e24eaf83182799f4f515ffb410d.tar.bz2
Re-do the broken-nice() patch to break less platforms. Hopefully none :P
Also note that it isn't just Linux nice() that is broken: at least FreeBSD and BSDI also have this problem. os.nice() should probably just be emulated using getpriority()/setpriority(), if they are available, but I'll get to that later.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 120c848..aec8caa 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1110,6 +1110,12 @@ posix_mkdir(PyObject *self, PyObject *args)
#ifdef HAVE_NICE
+#if defined(HAVE_BROKEN_NICE) && defined(HAVE_SYS_RESOURCE_H)
+#if defined(HAVE_GETPRIORITY) && !defined(PRIO_PROCESS)
+#include <sys/resource.h>
+#endif
+#endif
+
static char posix_nice__doc__[] =
"nice(inc) -> new_priority\n\
Decrease the priority of process and return new priority.";
@@ -1124,8 +1130,8 @@ posix_nice(PyObject *self, PyObject *args)
/* 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.
+ Linux/FreeBSD/BSDI 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
@@ -1134,7 +1140,7 @@ posix_nice(PyObject *self, PyObject *args)
errno = 0;
value = nice(increment);
-#ifdef HAVE_GETPRIORITY
+#if defined(HAVE_BROKEN_NICE) && defined(HAVE_GETPRIORITY)
if (value == 0)
value = getpriority(PRIO_PROCESS, 0);
#endif