Hi all,

I've searched various FAQ's, perldocs and the archive of the list, but
can't find any mention of this, so thought this list might be a good
source of advice.

What's the best/recommended way for a script to detect when it's running
under the debugger ?

I know you shouldn't need to know, but sometimes you do need to - in
this example I have a script that uses fork() on Win32 which the
debugger doesn't seem to enjoy (given that fork() on Win32 is an
emulated hack), so if I'm running in the debugger then it runs what
would be the child process synchronously.

So far I'm using

 # detect if we're running in the perl debugger - so far the test is a
hack !
 sub InDebugger
 {
    return exists($ENV{PERLDB_PIDS});
 }

which works, is cheap, and should be reasonably robust, but I was
wondering if there was a better way, something more stable to look for -
I could look for various namespaces existing but that seems a bit weak.

Cheers

--
Tim

Reply via email to