Use Linux-specific /proc/$PID/status file to check whether we're being debugged and a generic raise(SIGTRAP) to actually break into the debugger.