diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp index 1374d06f16b..68917967dc8 100644 --- a/src/libs/utils/consoleprocess_unix.cpp +++ b/src/libs/utils/consoleprocess_unix.cpp @@ -162,6 +162,7 @@ bool ConsoleProcess::start(const QString &program, const QString &args) << msgPromptToClose() << workingDirectory() << (d->m_tempFile ? d->m_tempFile->fileName() : QString()) + << QString::number(getpid()) << pcmd << pargs.toUnixArgs(); QString xterm = allArgs.takeFirst(); diff --git a/src/libs/utils/process_stub_unix.c b/src/libs/utils/process_stub_unix.c index 4a9df676b5c..efb2698402c 100644 --- a/src/libs/utils/process_stub_unix.c +++ b/src/libs/utils/process_stub_unix.c @@ -47,6 +47,16 @@ #include #include +#ifdef __linux__ +#include + +// Enable compilation with older header that doesn't contain this constant +// for running on newer libraries that do support it +#ifndef PR_SET_PTRACER +#define PR_SET_PTRACER 0x59616d61 +#endif +#endif + /* For OpenBSD */ #ifndef EPROTO # define EPROTO EINVAL @@ -90,6 +100,7 @@ enum { ArgMsg, ArgDir, ArgEnv, + ArgPid, ArgExe }; @@ -289,6 +300,7 @@ int main(int argc, char *argv[]) /* Get a SIGTRAP after exec() has loaded the new program. */ #ifdef __linux__ + prctl(PR_SET_PTRACER, atoi(argv[ArgPid])); ptrace(PTRACE_TRACEME); #else ptrace(PT_TRACE_ME, 0, 0, 0);