From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Jacobowitz To: "Glenn F. Maynard" Cc: gdb@sourceware.cygnus.com Subject: Re: gdb: detection and/or fork+gethostbyname crash workaround? Date: Tue, 24 Jul 2001 13:26:00 -0000 Message-id: <20010724132604.A18052@nevyn.them.org> References: <20010723210115.B1359@zewt.org> <1010724155219.ZM20181@ocotillo.lan> <20010724142248.A2923@zewt.org> X-SW-Source: 2001-07/msg00345.html On Tue, Jul 24, 2001 at 02:22:48PM -0400, Glenn F. Maynard wrote: > On Tue, Jul 24, 2001 at 08:52:19AM -0700, Kevin Buettner wrote: > > If it's one which uses ptrace(), the kernel usually prohibits two > > processes from invoking ptrace() on the same inferior. So one > > strategy might be to have the program in question cause ptrace to be > > invoked on itself. I don't think the process will be able to do this > > itself; I think it's likely that it would have to fork and let the > > child attempt this. The return status from wait() or waitpid() could > > indicate whether the attempt to invoke ptrace() was successful or not. > > That's what I tried (x86 Linux); a process can't ptrace itself. I could > fork a process to test this, I suppose; I'll try that. (Wouldn't it > be the return status from ptrace(), though? I assume it'd return something > like EPERM if a process is already being debugged.) Try ptrace( PTRACE_TRACEME, ...) ? -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer