Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Fix BackgroundCommand.send_signal() and add trace-cmd record support #689

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

douglas-raillard-arm
Copy link
Contributor

@douglas-raillard-arm douglas-raillard-arm commented May 30, 2024

Fixes #645
Supersedes #643

TODO:

  • Add/update docstrings
  • Figure out if moving some init logic for the various subclasses of BackgroundCommand inside the class would simplify the code and avoid BackgroundCommand.from_factory() layer.

@douglas-raillard-arm douglas-raillard-arm changed the title [draft] Fix BackgroundCommand.send_signal() and add trace-cmd record support [Draft] Fix BackgroundCommand.send_signal() and add trace-cmd record support May 30, 2024
@douglas-raillard-arm
Copy link
Contributor Author

Upon deeper inspection, the from_factory() solution is still better than moving the code from <subclass of Target>._background() to their associated BackgroundCommand subclass, as it typically requires using a bunch of private function/method from the connection type.

Support sending any signal to background commands, instead of only
supporting properly SIGKILL/SIGTERM/SIGQUIT.

The main issue is figuring out what PID to send the signal to, as the
devlib API allows running a whole snippet of shell script that typically
is wrapped under many layers of sh -c and sudo calls. In order to lift
the ambiguity, the user has access to a "devlib-signal-target" command
that points devlib at what process should be the target of signals:

    # Run a "setup" command, then the main command that will receive the
    # signals
    cmd = 'echo setup; devlib-signal-target echo hello world'
    with target.background(cmd) as bg:
	bg.communicate()

The devlib-signal-target script can only be used once per background
command, so that it is never ambiguous what process is targeted, and so
that the Python code can cache the target PID.  Subsequent invocations
of devlib-signal-target will fail.
Allow using trace-cmd record that continuously dump the trace to disk,
allowing to overcome the buffer size limitations when recording for
extended periods of time.
@douglas-raillard-arm
Copy link
Contributor Author

PR rebased

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BackgroundCommand signals don't propagate through some shell setups
1 participant