Skip to contentSkip to conversation

nice() return value is unreliable

Openvpn-devel Ian Pilcher 1 participant 1 message Feb 10, 2004

lore
Share & tools
lore
#0 lore raw

Attached is a small patch to set_nice() in misc.c that uses errno, rather than nice()'s return value to determine if the call succeeded. See 'man 2 nice' on a recent Linux distribution for why checking the return value is unreliable.

Signature · 3 lines
========================================================================
Ian Pilcher                                        [email protected]...
========================================================================
misc.c renamed from openvpn-1.5.0-orig/misc.c +3 -1
diff -urNp ../openvpn-1.5.0-orig/misc.c ./misc.c
@@ -139,7 +139,9 @@ set_nice (int niceval)
   if (niceval)
     {
 #ifdef HAVE_NICE
-      if (nice (niceval) < 0)
+      errno = 0;
+      nice (niceval);
+      if (errno != 0)
 	msg (M_WARN | M_ERRNO, "WARNING: nice %d failed", niceval);
       else
 	msg (M_INFO, "nice %d succeeded", niceval);