[Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.187.2.1,2.187.2.2
Thomas Wouters
twouters@users.sourceforge.net
Wed, 11 Jul 2001 07:01:10 -0700
- Previous message: [Python-checkins] CVS: python/dist/src acconfig.h,1.46,1.46.2.1 config.h.in,2.91.2.1,2.91.2.2 configure,1.207.2.1,1.207.2.2 configure.in,1.215.2.1,1.215.2.2
- Next message: [Python-checkins] CVS: python/dist/src config.h.in,2.91.2.2,2.91.2.3 configure.in,1.215.2.2,1.215.2.3 configure,1.207.2.2,1.207.2.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv27583/Modules
Modified Files:
Tag: release21-maint
posixmodule.c
Log Message:
Patch #439995 (slightly modified from the uploaded version):
Work around Linux's nonstandard nice() systemcall, which does not return the
new priority.
This closes SF bug #439990.
Index: posixmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v
retrieving revision 2.187.2.1
retrieving revision 2.187.2.2
diff -C2 -r2.187.2.1 -r2.187.2.2
*** posixmodule.c 2001/06/27 13:01:12 2.187.2.1
--- posixmodule.c 2001/07/11 14:01:08 2.187.2.2
***************
*** 1079,1084 ****
if (!PyArg_ParseTuple(args, "i:nice", &increment))
return NULL;
value = nice(increment);
! if (value == -1)
return posix_error();
return PyInt_FromLong((long) value);
--- 1079,1101 ----
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);
! #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);
- Previous message: [Python-checkins] CVS: python/dist/src acconfig.h,1.46,1.46.2.1 config.h.in,2.91.2.1,2.91.2.2 configure,1.207.2.1,1.207.2.2 configure.in,1.215.2.1,1.215.2.2
- Next message: [Python-checkins] CVS: python/dist/src config.h.in,2.91.2.2,2.91.2.3 configure.in,1.215.2.2,1.215.2.3 configure,1.207.2.2,1.207.2.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]