[patch] Fix `shell' command for async (PR 12850)

Pedro Alves pedro@codesourcery.com
Tue Jun 7 17:13:00 GMT 2011


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



More information about the Gdb-patches mailing list