davidbuxton / watchedinstall
fork of watchedinstall
Changes to Preston Holmes' tool for Mac OS X.
Clone this repository (size: 71.9 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/davidbuxton/watchedinstall/
| commit 32: | d97aaae628c3 |
| parent 31: | 74db22235f00 |
| branch: | default |
Write dtrace stdout to a temporary file instead of a pipe.
This fixes a race condition where dtrace received a SIGKILL then waited
to write to the stdout, but was finally sent SIGKILL which caused the
whole program to discard the event log.
Changed (Δ266 bytes):
raw changeset »
watchedinstall.py (8 lines added, 4 lines removed)
Up to file-list watchedinstall.py:
24 |
24 |
"""A tool for creating transcripts by noting changes made by an installer. |
25 |
25 |
""" |
26 |
26 |
from __future__ import with_statement |
27 |
from contextlib import contextmanager |
|
27 |
from contextlib import contextmanager, nested |
|
28 |
28 |
from optparse import OptionParser, OptionValueError |
29 |
29 |
from cStringIO import StringIO |
30 |
30 |
from subprocess import CalledProcessError |
| … | … | @@ -314,11 +314,14 @@ def watch_install_events(waitfor): |
314 |
314 |
"""Returns a triple of installer process ID, a list of process IDs and a |
315 |
315 |
list of filesystem changes that happened while waiting for waitfor to return. |
316 |
316 |
""" |
317 |
# This works around a problem where data was being dropped when using a PIPE |
|
317 |
# This works around a problem where data was being dropped when using a PIPE |
|
318 |
# and dtrace hanging after being sent SIGTERM which I guess is to do with |
|
319 |
# pipes blocking and creating a race condition. |
|
318 |
320 |
fs_events = tempfile.mkstemp()[1] |
321 |
pid_events = tempfile.mkstemp()[1] |
|
319 |
322 |
|
320 |
with open(fs_events, 'wb') as fs_handle: |
|
321 |
with read_program(EXECSNOOP_ARGS) as pid_events: |
|
323 |
with nested(open(fs_events, 'wb'), open(pid_events, 'wb')) as (fs_handle, pid_handle): |
|
324 |
with read_program(EXECSNOOP_ARGS, stdout=pid_handle): |
|
322 |
325 |
with read_program([FSWATCHER_CMD], stdout=fs_handle): |
323 |
326 |
# Wait for event logging processes to spin up |
324 |
327 |
sleep(1) |
| … | … | @@ -327,6 +330,7 @@ def watch_install_events(waitfor): |
327 |
330 |
|
328 |
331 |
# Return an iterable object |
329 |
332 |
fs_events = open(fs_events, 'r') |
333 |
pid_events = open(pid_events, 'r') |
|
330 |
334 |
|
331 |
335 |
return installer_pid, pid_events, fs_events |
332 |
336 |
