Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: infptrace fix
@ 2003-02-24 23:31 J. Johnston
  2003-02-25  0:10 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: J. Johnston @ 2003-02-24 23:31 UTC (permalink / raw)
  To: gdb-patches

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

The following patch fixes a problem on linux regarding attached
processes.  When gdb quits, it goes to detach the process.  If the
process has already been killed, the ptrace detach call sets errno.
This causes infptrace.c: detach() to issue a perror_with_name()
call which eventually gets caught and the user is returned to the
gdb prompt.  If we try and quit again, we go through the same
sequence and so on and so on.

The patch recognizes if errno is set to ESRCH, indicating that the
process cannot be found which is ok and should not result in an
error being flagged.

Ok to install?


-- Jeff J.

2003-02-24  Jeff Johnston  <jjohnstn@redhat.com>

	* infptrace.c (detach): Do not flag error if ptrace detach fails and
	errno is set to ESRCH.


[-- Attachment #2: infptrace.patch --]
[-- Type: text/plain, Size: 495 bytes --]

Index: infptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infptrace.c,v
retrieving revision 1.22
diff -u -r1.22 infptrace.c
--- infptrace.c	8 Nov 2002 23:48:38 -0000	1.22
+++ infptrace.c	24 Feb 2003 23:26:22 -0000
@@ -301,7 +301,7 @@
   errno = 0;
   ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1,
           signal);
-  if (errno)
+  if (errno && errno != ESRCH)
     perror_with_name ("ptrace");
   attach_flag = 0;
 }

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

* Re: RFA: infptrace fix
  2003-02-24 23:31 RFA: infptrace fix J. Johnston
@ 2003-02-25  0:10 ` Kevin Buettner
  2003-02-25 19:40   ` J. Johnston
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2003-02-25  0:10 UTC (permalink / raw)
  To: J. Johnston, gdb-patches

On Feb 24,  6:31pm, J. Johnston wrote:

> The following patch fixes a problem on linux regarding attached
> processes.  When gdb quits, it goes to detach the process.  If the
> process has already been killed, the ptrace detach call sets errno.
> This causes infptrace.c: detach() to issue a perror_with_name()
> call which eventually gets caught and the user is returned to the
> gdb prompt.  If we try and quit again, we go through the same
> sequence and so on and so on.
> 
> The patch recognizes if errno is set to ESRCH, indicating that the
> process cannot be found which is ok and should not result in an
> error being flagged.
> 
> Ok to install?
> 
> 
> -- Jeff J.
> 
> 2003-02-24  Jeff Johnston  <jjohnstn@redhat.com>
> 
> 	* infptrace.c (detach): Do not flag error if ptrace detach fails and
> 	errno is set to ESRCH.

This is okay.

(For other errors during detach, I wonder if it'd make sense to just
issue a warning which decodes the errno...)

Kevin


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

* Re: RFA: infptrace fix
  2003-02-25  0:10 ` Kevin Buettner
@ 2003-02-25 19:40   ` J. Johnston
  0 siblings, 0 replies; 3+ messages in thread
From: J. Johnston @ 2003-02-25 19:40 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

Kevin Buettner wrote:
> On Feb 24,  6:31pm, J. Johnston wrote:
> 
> 
>>The following patch fixes a problem on linux regarding attached
>>processes.  When gdb quits, it goes to detach the process.  If the
>>process has already been killed, the ptrace detach call sets errno.
>>This causes infptrace.c: detach() to issue a perror_with_name()
>>call which eventually gets caught and the user is returned to the
>>gdb prompt.  If we try and quit again, we go through the same
>>sequence and so on and so on.
>>
>>The patch recognizes if errno is set to ESRCH, indicating that the
>>process cannot be found which is ok and should not result in an
>>error being flagged.
>>
>>Ok to install?
>>
>>
>>-- Jeff J.
>>
>>2003-02-24  Jeff Johnston  <jjohnstn@redhat.com>
>>
>>	* infptrace.c (detach): Do not flag error if ptrace detach fails and
>>	errno is set to ESRCH.
> 
> 
> This is okay.
> 
> (For other errors during detach, I wonder if it'd make sense to just
> issue a warning which decodes the errno...)
>

Thanks Kevin.  Patch applied.  I also wondered if a warning should be issued
but I do not know what other errors can occur with the detach operation.  I
also considered moving the attached_flag reset to before the error check so
at least we didn't come back to detach it again and again.

-- Jeff J.




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

end of thread, other threads:[~2003-02-25 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-24 23:31 RFA: infptrace fix J. Johnston
2003-02-25  0:10 ` Kevin Buettner
2003-02-25 19:40   ` J. Johnston

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