This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A question about target_wait TARGET_WNOHANG and linux_nat_wait_1


Hi guys,

I found that target_wait TARGET_WNOHANG is used in
fetch_inferior_event, and the comment of this function is:
/* Asynchronous version of wait_for_inferior. It is called by the
   event loop whenever a change of state is detected on the file
   descriptor corresponding to the target. It can be called more than
   once to complete a single execution command. In such cases we need
   to keep the state in a global variable ECSS. If it is the last time
   that this function is called for a single execution command, then
   report to the user that the inferior has stopped, and do the
   necessary cleanups. */

So I think we want target_wait TARGET_WNOHANG can exec unblock, right?


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)
	{

      /* We shouldn't end up here unless we want to try again.  */
      gdb_assert (lp == NULL);
    }

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.
So the TARGET_WNOHANG is useless.


What about add a handler to deal with "TARGET_WNOHANG" and let it
return at once in my_waitpid loop?


Thanks,
Hui


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]