]> git.meshlink.io Git - meshlink/commitdiff
Use setpriority() instead of nice() on UNIX-like systems.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 20 Nov 2010 14:31:11 +0000 (14:31 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 20 Nov 2010 14:31:11 +0000 (14:31 +0000)
The return value of nice() can not reliably indicate errors. The return value
of the setpriority() call is well-defined.

src/tincd.c

index 3dab9a01157b5751c14a65f24fc3d82ae94ea94f..775815118b6486cc5ec70f56ad4c065c81f49f62 100644 (file)
@@ -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) {