34
34
:return: a tuple: function-result, a StraceResult.
36
# FIXME: strace is buggy
37
# (https://bugs.launchpad.net/ubuntu/+source/strace/+bug/103133) and the
38
# test suite hangs if the '-f' is given to strace *and* more than one
39
# thread is running. The following allows the test suite to disable fork
40
# following to work around the bug. It's a bit dirty to pollute the kwargs
41
# so we take a likely-to-be-unique name to avoid conflicts (*args and
42
# *kwargs are related to 'function').
43
follow_childrens = kwargs.pop('strace_follow_childrens', True)
36
44
# capture strace output to a file
37
45
log_file = tempfile.NamedTemporaryFile()
38
46
log_file_fd = log_file.fileno()
41
proc = subprocess.Popen(['strace',
42
'-f', '-r', '-tt', '-p', str(pid), '-o', log_file.name
44
stdout=subprocess.PIPE,
45
stderr=subprocess.STDOUT)
49
strace_cmd = ['strace', '-r', '-tt', '-p', str(pid), '-o', log_file.name]
51
strace_args.append('-f')
52
proc = subprocess.Popen(strace_cmd,
53
stdout=subprocess.PIPE,
54
stderr=subprocess.STDOUT)
46
55
# Wait for strace to attach
47
56
attached_notice = proc.stdout.readline()
48
57
# Run the function to strace