Created
December 10, 2019 09:38
-
-
Save tahaconfiant/55a394a0ae153ec71f82a83174447f8d to your computer and use it in GitHub Desktop.
waitpid_callback_kill_child
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def waitpid_callback(frame, bp_loc, dict): | |
print ("waitpid() detected!") | |
# let's attach to the child process: | |
# get the current process id | |
curr_target = frame.thread.process.GetTarget() | |
pid = frame.thread.process.GetProcessID() | |
print ("current pid is %s\n" % str(pid)) | |
# let get the current filename of the current target | |
file_name = curr_target.GetExecutable().GetFilename() | |
print ("attempting to attach to any new instance of %s" % file_name) | |
# we have to detach from the parent process | |
frame.thread.process.Detach() | |
child_pid = get_child_pid(file_name, pid) | |
# Let's attempt to attach to the child process | |
listener = lldb.SBListener('listener') | |
error = lldb.SBError() | |
child = curr_target.AttachToProcessWithID(listener, child_pid, error) | |
if not error.Success(): | |
print ("error %s\n", error.GetCString()) | |
raise Exception('Failed to attach to the process.') | |
assert child.IsValid() | |
else: | |
print ("sucessfully attached to child, with pid : %s\n" % str(child.GetProcessID())) | |
# we stop and kill the child | |
print ("killing the child process") | |
child.Stop() | |
child.Kill() | |
print ("bundlore_python_dump has finished, dumped python code is here: /tmp/dumped.py") | |
# we stop and kill the parent | |
frame.thread.process.Stop() | |
frame.thread.process.Kill() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment