Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] gdbserver, errno handling in my_waitpid
@ 2010-03-10 21:25 Michael Snyder
  2010-03-10 21:30 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Snyder @ 2010-03-10 21:25 UTC (permalink / raw)
  To: gdb-patches, Doug Evans, dan

[-- Attachment #1: Type: text/plain, Size: 233 bytes --]

This is not really my most familiar bit of the code, so
you gdbserver guys check me, ok?

It seems to me that we need to set errno to zero before calling waitpid,
if we're going to check it right after.  Especially the second time.


[-- Attachment #2: errno.txt --]
[-- Type: text/plain, Size: 825 bytes --]

2010-03-10  Michael Snyder  <msnyder@vmware.com>

	* linux-low.c (my_waitpid): Set errno to 0 before waitpid.

Index: linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.130
diff -u -p -r1.130 linux-low.c
--- linux-low.c	6 Mar 2010 00:11:42 -0000	1.130
+++ linux-low.c	10 Mar 2010 21:20:14 -0000
@@ -309,6 +309,7 @@ my_waitpid (int pid, int *status, int fl
 	{
 	  /* Since all signals are blocked, there's no need to check
 	     for EINTR here.  */
+	  errno = 0;
 	  ret = waitpid (pid, status, flags);
 	  out_errno = errno;
 
@@ -338,6 +339,7 @@ my_waitpid (int pid, int *status, int fl
     }
   else
     {
+      errno = 0;
       do
 	ret = waitpid (pid, status, flags);
       while (ret == -1 && errno == EINTR);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] gdbserver, errno handling in my_waitpid
  2010-03-10 21:25 [RFA] gdbserver, errno handling in my_waitpid Michael Snyder
@ 2010-03-10 21:30 ` Pedro Alves
  2010-03-10 21:48   ` Michael Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2010-03-10 21:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Michael Snyder, Doug Evans, dan

On Wednesday 10 March 2010 21:24:57, Michael Snyder wrote:
> This is not really my most familiar bit of the code, so
> you gdbserver guys check me, ok?
> 
> It seems to me that we need to set errno to zero before calling waitpid,
> if we're going to check it right after.  Especially the second time.

I don't think do; we only check it if waitpid returns -1, and
in that case, waitpid should have changed errno itself.  Or
have you found an actual problem here?

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] gdbserver, errno handling in my_waitpid
  2010-03-10 21:30 ` Pedro Alves
@ 2010-03-10 21:48   ` Michael Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Snyder @ 2010-03-10 21:48 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Doug Evans, dan

Pedro Alves wrote:
> On Wednesday 10 March 2010 21:24:57, Michael Snyder wrote:
>> This is not really my most familiar bit of the code, so
>> you gdbserver guys check me, ok?
>>
>> It seems to me that we need to set errno to zero before calling waitpid,
>> if we're going to check it right after.  Especially the second time.
> 
> I don't think do; we only check it if waitpid returns -1, and
> in that case, waitpid should have changed errno itself.  Or
> have you found an actual problem here?
> 

No, I guess you're right -- it just looked suspicious to me.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-10 21:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-10 21:25 [RFA] gdbserver, errno handling in my_waitpid Michael Snyder
2010-03-10 21:30 ` Pedro Alves
2010-03-10 21:48   ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox