From: Guus Sliepen Date: Sat, 20 Nov 2010 14:31:11 +0000 (+0000) Subject: Use setpriority() instead of nice() on UNIX-like systems. X-Git-Tag: release-1.0.14~23 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=cac0a5c651535e8317839b0deff1ee98086a8184;ds=sidebyside Use setpriority() instead of nice() on UNIX-like systems. The return value of nice() can not reliably indicate errors. The return value of the setpriority() call is well-defined. --- diff --git a/src/tincd.c b/src/tincd.c index 3dab9a01..77581511 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -502,12 +502,12 @@ static bool drop_privs() { } #ifdef HAVE_MINGW -# define setpriority(level) SetPriorityClass(GetCurrentProcess(), level) +# define setpriority(level) SetPriorityClass(GetCurrentProcess(), (level)) #else # define NORMAL_PRIORITY_CLASS 0 # define BELOW_NORMAL_PRIORITY_CLASS 10 # define HIGH_PRIORITY_CLASS -10 -# define setpriority(level) nice(level) +# define setpriority(level) (setpriority(PRIO_PROCESS, 0, (level))) #endif int main(int argc, char **argv) {