File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1121,8 +1121,25 @@ posix_nice(PyObject *self, PyObject *args)
11211121
11221122 if (!PyArg_ParseTuple (args , "i:nice" , & increment ))
11231123 return NULL ;
1124+
1125+ /* There are two flavours of 'nice': one that returns the new
1126+ priority (as required by almost all standards out there) and the
1127+ Linux one, which returns '0' on success and advices the use of
1128+ getpriority() to get the new priority.
1129+
1130+ If we are of the nice family that returns the new priority, we
1131+ need to clear errno before the call, and check if errno is filled
1132+ before calling posix_error() on a returnvalue of -1, because the
1133+ -1 may be the actual new priority! */
1134+
1135+ errno = 0 ;
11241136 value = nice (increment );
1125- if (value == -1 )
1137+ #ifdef HAVE_GETPRIORITY
1138+ if (value == 0 )
1139+ value = getpriority (PRIO_PROCESS , 0 );
1140+ #endif
1141+ if (value == -1 && errno != 0 )
1142+ /* either nice() or getpriority() returned an error */
11261143 return posix_error ();
11271144 return PyInt_FromLong ((long ) value );
11281145}
Original file line number Diff line number Diff line change 1- /* config.h.in. Generated automatically from configure.in by autoheader. */
1+ /* config.h.in. Generated automatically from configure.in by autoheader 2.13 . */
22
33/* Define if on AIX 3.
44 System headers sometimes define this.
299299/* The number of bytes in a wchar_t. */
300300#undef SIZEOF_WCHAR_T
301301
302+ /* Define if you have the _getpty function. */
303+ #undef HAVE__GETPTY
304+
302305/* Define if you have the alarm function. */
303306#undef HAVE_ALARM
304307
392395/* Define if you have the getpid function. */
393396#undef HAVE_GETPID
394397
395- /* Define if you have the _getpty function. */
396- #undef HAVE__GETPTY
398+ /* Define if you have the getpriority function. */
399+ #undef HAVE_GETPRIORITY
397400
398401/* Define if you have the getpwent function. */
399402#undef HAVE_GETPWENT
557560/* Define if you have the waitpid function. */
558561#undef HAVE_WAITPID
559562
560- /* Define if you have the <db_185 .h> header file. */
561- #undef HAVE_DB_185_H
563+ /* Define if you have the <db .h> header file. */
564+ #undef HAVE_DB_H
562565
563566/* Define if you have the <db1/ndbm.h> header file. */
564567#undef HAVE_DB1_NDBM_H
565568
566- /* Define if you have the <db .h> header file. */
567- #undef HAVE_DB_H
569+ /* Define if you have the <db_185 .h> header file. */
570+ #undef HAVE_DB_185_H
568571
569572/* Define if you have the <dirent.h> header file. */
570573#undef HAVE_DIRENT_H
You can’t perform that action at this time.
0 commit comments