[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug and feature request in nice
From: |
Paul Eggert |
Subject: |
Re: Bug and feature request in nice |
Date: |
Fri, 22 Apr 2005 23:03:25 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
Behdad Esfahbod <address@hidden> writes:
> address@hidden ~]$ nice -n10 -p 10577
> -n10: invalid option -- p
Thanks for reporting that. I installed the patch enclosed below.
> Next, a feature request: nice with -p should be alter the
> priority of a running process. That's perfectly possible as many
> tools already do that.
OK, but is there any precedent for that? I thought this was renice's job.
2005-04-22 Paul Eggert <address@hidden>
* src/nice.c (main): Report proper program name when getopt finds
trouble. Problem reported by Behdad Esfahbod.
--- nice.c 5 Apr 2005 11:53:53 -0000 1.78
+++ nice.c 23 Apr 2005 05:39:55 -0000 1.79
@@ -116,7 +116,7 @@ main (int argc, char **argv)
for (i = 1; i < argc; /* empty */)
{
- char *s = argv[i];
+ char const *s = argv[i];
if (s[0] == '-' && ISDIGIT (s[1 + (s[1] == '-' || s[1] == '+')])
&& posix2_version () < 200112)
@@ -127,28 +127,23 @@ main (int argc, char **argv)
else
{
int optc;
- char **fake_argv = argv + i - 1;
+ int fake_argc = argc - (i - 1);
+ char **fake_argv = argv + (i - 1);
+
+ /* Ensure that any getopt diagnostics use the right name. */
+ fake_argv[0] = program_name;
/* Initialize getopt_long's internal state. */
optind = 0;
- if ((optc = getopt_long (argc - (i - 1), fake_argv, "+n:",
- longopts, NULL)) != -1)
- {
- switch (optc)
- {
- case '?':
- usage (EXIT_FAIL);
-
- case 'n':
- adjustment_given = optarg;
- break;
- }
- }
-
+ optc = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL);
i += optind - 1;
- if (optc == EOF)
+ if (optc == '?')
+ usage (EXIT_FAIL);
+ else if (optc == 'n')
+ adjustment_given = optarg;
+ else /* optc == -1 */
break;
}
}