A question about target_wait TARGET_WNOHANG and linux_nat_wait_1

Hui Zhu teawater@gmail.com
Tue Oct 6 16:27:00 GMT 2009


Thanks Pedro, I am clear with it now.

I have another question about it.

>       if (pid == -1)
>         {

...
         /* And every time we have checked both:
            In async mode, return to event loop;
            In sync mode, suspend waiting for a SIGCHLD signal.  */
         if (options & __WCLONE)
           {

It just handle the "minus_one_ptid".

How did it handle the inferior_ptid?

Thanks,
Hui

On Wed, Oct 7, 2009 at 00:04, Pedro Alves <pedro@codesourcery.com> wrote:
> On Tuesday 06 October 2009 16:54:43, Hui Zhu wrote:
>> But if the TARGET_WNOHANG let wait return with a block threads, it
>> will return 0.
>> But if lwpid is 0, the wait will keep running, the wait is blocked.
>
> You've snipped the important bit:
>
>> But I found in linux_nat_wait_1:
>>   while (lp == NULL)
>>     {
>>       pid_t lwpid;
>>
>>       lwpid = my_waitpid (pid, &status, options);
>>
>>       if (lwpid > 0)
>>         {
>> ...
>>       if (pid == -1)
>>         {
>
> ...
>          /* And every time we have checked both:
>             In async mode, return to event loop;
>             In sync mode, suspend waiting for a SIGCHLD signal.  */
>          if (options & __WCLONE)
>            {
>              if (target_options & TARGET_WNOHANG)
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>                {
>                  /* No interesting event.  */
>                  ourstatus->kind = TARGET_WAITKIND_IGNORE;
>
>                  if (debug_linux_nat_async)
>                    fprintf_unfiltered (gdb_stdlog, "LLW: exit (ignore)\n");
>
>                  restore_child_signals_mask (&prev_mask);
>                  return minus_one_ptid;
>                  ^^^^^^^^^^^^^^^^^^^^^^
>                }
>
>              sigsuspend (&suspend_mask);
>            }
>
> ...
>
>>
>>       /* We shouldn't end up here unless we want to try again.  */
>>       gdb_assert (lp == NULL);
>>     }
>
> We always iterate at least twice, even with TARGET_WNOHANG, to
> wait for clone and non-clone LWPs.  See the comment about __WALL at the
> top of the file.  There's a description of async mode handling
> nearby too.
>
>> So the TARGET_WNOHANG is useless.
>
> Not at all.
>
> --
> Pedro Alves
>



More information about the Gdb mailing list