You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I apologize if this is an ignorant question. I have a parent process which spawns two children and I need one of the children (created via multiprocessing) to be able to ptrace the other (started via subprocess.Popen) but I am recieving the permission error: ptrace.error.PtraceError: ptrace(cmd=16, pid=15151, 0, 0) error #1: Operation not permitted
Here is sample code that demonstrates what I am trying to do and the error I am encountering:
import multiprocessing
import subprocess
import time
import ptrace.debugger
def ptrace_test(pid):
debugger = ptrace.debugger.PtraceDebugger()
process = debugger.addProcess(pid, False)
# Other stuff
child = subprocess.Popen("/usr/bin/ls")
proc = multiprocessing.Process(target=ptrace_test, args=(child.pid,))
proc.start()
proc.join()
The text was updated successfully, but these errors were encountered:
There are several reasons this can happen, see here.
If due to the YAMA feature (probably if on recent Ubuntu), then you can use prctl.set_ptracer in the tracee with the tracer pid and signal.pause() until the tracer attaches. You may be able to use the preexec_fn argument to Popen for this but there are a lot of warnings about it in the documentation - it may be better to start a multiprocessing.Process that creates the subprocess after the tracer attaches.
I apologize if this is an ignorant question. I have a parent process which spawns two children and I need one of the children (created via
multiprocessing
) to be able to ptrace the other (started viasubprocess.Popen
) but I am recieving the permission error:ptrace.error.PtraceError: ptrace(cmd=16, pid=15151, 0, 0) error #1: Operation not permitted
Here is sample code that demonstrates what I am trying to do and the error I am encountering:
The text was updated successfully, but these errors were encountered: