This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix `shell' command for async (PR 12850)
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Tue, 7 Jun 2011 18:13:24 +0100
- Subject: Re: [patch] Fix `shell' command for async (PR 12850)
- References: <20110607152409.GA7600@host1.jankratochvil.net>
On Tuesday 07 June 2011 16:24:09, Jan Kratochvil wrote:
> Hi,
>
> this was completely debugged by Pedro so just wrote it and posted.
Thanks! And thanks for writing a test as well.
> --- a/gdb/cli/cli-cmds.c
> +++ b/gdb/cli/cli-cmds.c
> @@ -750,7 +750,7 @@ shell_escape (char *arg, int from_tty)
> }
>
> if (pid != -1)
> - while ((rc = wait (&status)) != pid && rc != -1)
> + while ((rc = waitpid (pid, &status, 0)) != pid && rc != -1)
> ;
Pedantically, I think this could be simplified. PID is
a specific pid, not -1, and when WNOHANG is not used,
waitpid(pid, ..., 0) can only return pid or -1.
Thus, the loop only ever executes once.
> +++ b/gdb/rs6000-nat.c
> @@ -614,7 +614,7 @@ exec_one_dummy_insn (struct regcache *regcache)
(Urgh, had never seen this bizarre code before. I wonder if
this is still needed on any sane platform, or if it was only
necessary on some ancient aix.)
--
Pedro Alves