diff options
-rw-r--r-- | src/libs/utils/consoleprocess_unix.cpp | 1 | ||||
-rw-r--r-- | src/libs/utils/process_stub_unix.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/libs/utils/consoleprocess_unix.cpp b/src/libs/utils/consoleprocess_unix.cpp index 1374d06f16..68917967dc 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 4a9df676b5..efb2698402 100644 --- a/src/libs/utils/process_stub_unix.c +++ b/src/libs/utils/process_stub_unix.c @@ -47,6 +47,16 @@ #include <errno.h> #include <assert.h> +#ifdef __linux__ +#include <sys/prctl.h> + +// 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); |