~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/strace.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-04 14:02:09 UTC
  • mfrom: (2584.1.1 Aaron's integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070704140209-ldl1njlpcclszadu
Fix #102019 by not asking strace to follow children

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
    :return: a tuple: function-result, a StraceResult.
35
35
    """
 
36
    return strace_detailed(function, args, kwargs)
 
37
 
 
38
 
 
39
def strace_detailed(function, args, kwargs, follow_children=True):
 
40
    # FIXME: strace is buggy
 
41
    # (https://bugs.launchpad.net/ubuntu/+source/strace/+bug/103133) and the
 
42
    # test suite hangs if the '-f' is given to strace *and* more than one
 
43
    # thread is running. Using follow_children=False allows the test suite to
 
44
    # disable fork following to work around the bug.
 
45
 
36
46
    # capture strace output to a file
37
47
    log_file = tempfile.NamedTemporaryFile()
38
48
    log_file_fd = log_file.fileno()
39
49
    pid = os.getpid()
40
50
    # start strace
41
 
    proc = subprocess.Popen(['strace',
42
 
        '-f', '-r', '-tt', '-p', str(pid), '-o', log_file.name
43
 
        ],
44
 
        stdout=subprocess.PIPE,
45
 
        stderr=subprocess.STDOUT)
 
51
    strace_cmd = ['strace', '-r', '-tt', '-p', str(pid), '-o', log_file.name]
 
52
    if follow_children:
 
53
        strace_args.append('-f')
 
54
    proc = subprocess.Popen(strace_cmd,
 
55
                            stdout=subprocess.PIPE,
 
56
                            stderr=subprocess.STDOUT)
46
57
    # Wait for strace to attach
47
58
    attached_notice = proc.stdout.readline()
48
59
    # Run the function to strace