Skip to content

Commit

Permalink
Merge pull request #11 from winson0123/clone3
Browse files Browse the repository at this point in the history
Support for clone3 syscall
  • Loading branch information
mgedmin committed Apr 18, 2024
2 parents 485d08d + 8915061 commit bb61f62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions strace_process_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ def __str__(self):
def simplify_syscall(event):
# clone(child_stack=0x..., flags=FLAGS, parent_tidptr=..., tls=...,
# child_tidptr=...) => clone(FLAGS)
if event.startswith('clone('):
if event.startswith(('clone(', 'clone3(')):
event = re.sub('[(].*, flags=([^,]*), .*[)]', r'(\1)', event)
return event.rstrip()


def extract_command_line(event):
# execve("/usr/bin/foo", ["foo", "bar"], [/* 45 vars */]) => foo bar
# execve("/usr/bin/foo", ["foo", "bar"], [/* 1 var */]) => foo bar
if event.startswith('clone('):
if event.startswith(('clone(', 'clone3(')):
if 'CLONE_THREAD' in event:
return '(thread)'
elif 'flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD' in event:
Expand Down Expand Up @@ -415,7 +415,7 @@ def parse_stream(event_stream, mogrifier=extract_command_line):
if result == '0':
name = mogrifier(args)
tree.handle_exec(e.pid, name, timestamp)
if e.event.startswith(('clone(', 'fork(', 'vfork(')):
if e.event.startswith(('clone(', 'clone3(', 'fork(', 'vfork(')):
args, equal, result = e.event.rpartition(' = ')
# if clone() fails, the event will look like this:
# clone(...) = -1 EPERM (Operation not permitted)
Expand Down

0 comments on commit bb61f62

Please sign in to comment.