summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-09-09 20:47:46 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-09-09 20:47:46 +0000
commit3de440458dc025ccc0a999fe8fc7ceb526470407 (patch)
treee46979479c548b1fd213184b328468824a5b3b34
parent590a4f3a553773d5804c3e9c4685ed52978fa171 (diff)
downloadcoreutils-3de440458dc025ccc0a999fe8fc7ceb526470407.tar.xz
(main): Hoist errno=0 outside the ifdef.
-rw-r--r--src/nice.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/nice.c b/src/nice.c
index 26b56b46c..7f19aeb1b 100644
--- a/src/nice.c
+++ b/src/nice.c
@@ -1,4 +1,4 @@
-/* nice -- run a program with modified nice value
+/* nice -- run a program with modified niceness
Copyright (C) 1990-2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -27,7 +27,7 @@
#include "system.h"
-#ifndef NICE_PRIORITY
+#if ! HAVE_NICE
/* Include this after "system.h" so we're sure to have definitions
(from time.h or sys/time.h) required for e.g. the ru_utime member. */
# include <sys/resource.h>
@@ -43,7 +43,7 @@
#define AUTHORS "David MacKenzie"
-#ifdef NICE_PRIORITY
+#if HAVE_NICE
# define GET_NICENESS() nice (0)
#else
# define GET_NICENESS() getpriority (PRIO_PROCESS, 0)
@@ -167,7 +167,7 @@ main (int argc, char **argv)
error (0, 0, _("a command must be given with an adjustment"));
usage (EXIT_FAIL);
}
- /* No command given; print the nice value. */
+ /* No command given; print the niceness. */
errno = 0;
current_niceness = GET_NICENESS ();
if (current_niceness == -1 && errno != 0)
@@ -176,15 +176,14 @@ main (int argc, char **argv)
exit (EXIT_SUCCESS);
}
-#ifndef NICE_PRIORITY
errno = 0;
+#if HAVE_NICE
+ ok = (nice (adjustment) != -1 || errno == 0);
+#else
current_niceness = GET_NICENESS ();
if (current_niceness == -1 && errno != 0)
error (EXIT_FAIL, errno, _("cannot get niceness"));
ok = (setpriority (PRIO_PROCESS, 0, current_niceness + adjustment) == 0);
-#else
- errno = 0;
- ok = (nice (adjustment) != -1 || errno == 0);
#endif
if (!ok)
error (errno == EPERM ? 0 : EXIT_FAIL, errno, _("cannot set niceness"));