mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
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.
This commit is contained in:
parent
109d986bfc
commit
c2c12dc31c
4 changed files with 317 additions and 286 deletions
|
|
@ -1121,8 +1121,25 @@ posix_nice(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i:nice", &increment))
|
if (!PyArg_ParseTuple(args, "i:nice", &increment))
|
||||||
return NULL;
|
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);
|
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 posix_error();
|
||||||
return PyInt_FromLong((long) value);
|
return PyInt_FromLong((long) value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
config.h.in
17
config.h.in
|
|
@ -1,4 +1,4 @@
|
||||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
|
||||||
|
|
||||||
/* Define if on AIX 3.
|
/* Define if on AIX 3.
|
||||||
System headers sometimes define this.
|
System headers sometimes define this.
|
||||||
|
|
@ -299,6 +299,9 @@
|
||||||
/* The number of bytes in a wchar_t. */
|
/* The number of bytes in a wchar_t. */
|
||||||
#undef SIZEOF_WCHAR_T
|
#undef SIZEOF_WCHAR_T
|
||||||
|
|
||||||
|
/* Define if you have the _getpty function. */
|
||||||
|
#undef HAVE__GETPTY
|
||||||
|
|
||||||
/* Define if you have the alarm function. */
|
/* Define if you have the alarm function. */
|
||||||
#undef HAVE_ALARM
|
#undef HAVE_ALARM
|
||||||
|
|
||||||
|
|
@ -392,8 +395,8 @@
|
||||||
/* Define if you have the getpid function. */
|
/* Define if you have the getpid function. */
|
||||||
#undef HAVE_GETPID
|
#undef HAVE_GETPID
|
||||||
|
|
||||||
/* Define if you have the _getpty function. */
|
/* Define if you have the getpriority function. */
|
||||||
#undef HAVE__GETPTY
|
#undef HAVE_GETPRIORITY
|
||||||
|
|
||||||
/* Define if you have the getpwent function. */
|
/* Define if you have the getpwent function. */
|
||||||
#undef HAVE_GETPWENT
|
#undef HAVE_GETPWENT
|
||||||
|
|
@ -557,14 +560,14 @@
|
||||||
/* Define if you have the waitpid function. */
|
/* Define if you have the waitpid function. */
|
||||||
#undef HAVE_WAITPID
|
#undef HAVE_WAITPID
|
||||||
|
|
||||||
/* Define if you have the <db_185.h> header file. */
|
/* Define if you have the <db.h> header file. */
|
||||||
#undef HAVE_DB_185_H
|
#undef HAVE_DB_H
|
||||||
|
|
||||||
/* Define if you have the <db1/ndbm.h> header file. */
|
/* Define if you have the <db1/ndbm.h> header file. */
|
||||||
#undef HAVE_DB1_NDBM_H
|
#undef HAVE_DB1_NDBM_H
|
||||||
|
|
||||||
/* Define if you have the <db.h> header file. */
|
/* Define if you have the <db_185.h> header file. */
|
||||||
#undef HAVE_DB_H
|
#undef HAVE_DB_185_H
|
||||||
|
|
||||||
/* Define if you have the <dirent.h> header file. */
|
/* Define if you have the <dirent.h> header file. */
|
||||||
#undef HAVE_DIRENT_H
|
#undef HAVE_DIRENT_H
|
||||||
|
|
|
||||||
|
|
@ -1175,7 +1175,7 @@ AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
|
||||||
setlocale setregid setreuid setsid setpgid setuid setvbuf \
|
setlocale setregid setreuid setsid setpgid setuid setvbuf \
|
||||||
sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
|
sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
|
||||||
tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
|
||||||
truncate uname waitpid _getpty)
|
truncate uname waitpid _getpty getpriority)
|
||||||
|
|
||||||
# check for openpty and forkpty
|
# check for openpty and forkpty
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue