DIFFER has a hook to run commands prior to a trace running and after it is complete within the TraceHook base class. We need a third hook that is triggered after a sample has started and after some configurable delay to allow the sample to actually begin running. This hook needs to be available both within the TraceHook class and in the generic hook configuration, #5.
The trace template will need a new configuration option that controls how long to wait prior to running any hooks during execution. In general, the executor run_trace will look something like:
trace.process = subprocess.Popen(
args,
cwd=str(trace.cwd),
stdout=trace.stdout_path.open('w'),
stderr=trace.stderr_path.open('w'),
stdin=subprocess.DEVNULL,
)
try:
trace.process.wait(trace.template.hook_delay) # feel free to rename the config option
except subprocess.TimeoutExpired:
# this is ok
self.run_trace_hooks(trace) # run the hooks while the process is running
else:
# the process finished, which might be ok depending on the configuration
pass # do something
trace.process.wait()
DIFFER has a hook to run commands prior to a trace running and after it is complete within the
TraceHook
base class. We need a third hook that is triggered after a sample has started and after some configurable delay to allow the sample to actually begin running. This hook needs to be available both within theTraceHook
class and in the generic hook configuration, #5.The trace template will need a new configuration option that controls how long to wait prior to running any hooks during execution. In general, the executor
run_trace
will look something like: