Skip to content

Conversation

@marcbonnici
Copy link
Collaborator

Fix a number of issues discovered during testing of #618.

  • Update kill command syntax to match the currently support busybox implementation.
  • Ensure the correct signal is to send to a command.
  • Prevent commands from being killed multiple times.

The kill applet in the current busybox executable does not support
the `--` syntax therefore remove from the template command.
The signal parameter was being ignored and instead always sending
the KILL signal instead.
# Otherwise wait for the full timeout and kill it
if self.poll() is None:
# Otherwise wait for the full timeout and if still alive kill it
if self.poll() is None and self.redirect_thread.is_alive():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@douglas-raillard-arm I'm not sure if this is the best way to detect whether the the command is still alive (or if it even makes sense as it is).
Do you have any thoughts on a better way to handle this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.poll() really should be enough. If the command is alive, it's supposed to return None. When it's dead, it returns the exit code. If that's not the case it's poll() that needs fixing, not its call sites.

The API is modeled after Popen.poll: https://docs.python.org/3/library/subprocess.html#subprocess.Popen.poll

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool thanks, during my testing poll() was always returning None regardless of the command status so will take a closer look at what is going on there.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which connection class where you using for your tests ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was using an SSH connection.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll also try to have a look tomorrow then

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the offer, however on further investigation please ignore me.
After resetting my environment and board I can no long reproduce the original issue so I think I must have had something in a strange state and things are now working as expected.
I am however tempted to leave the additional poll in place if that still makes sense.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is real, there was a missing return in wait() following #626 . I've been doing mostly Rust recently ...

Here is the fix, feel free to just integrate it in your PR if you want to avoid merge conflicts: #629

I am however tempted to leave the additional poll in place if that still makes sense.

The exact same condition is tested in ParamikoBackgroundCommand._poll so it won't add anything:

    def _poll(self):
        if self.redirect_thread.is_alive():
            return None
        elif self.chan.exit_status_ready():
            return self.wait()
        else:
            return None

Copy link
Collaborator Author

@marcbonnici marcbonnici May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is real, there was a missing return

Oh great, thank you for finding that, I was a rather confused at what was going on..

The exact same condition is tested in ParamikoBackgroundCommand._poll so it won't add anything

Good point thanks, I'll drop this change and pull your commit in instead.

Lack of return statement in wait() was making it return None instead of
the exit code. Add appropriate return statement in wait() and other
function to ensure return value is not lost.
@marcbonnici marcbonnici merged commit ac0c39e into ARM-software:master May 17, 2023
@marcbonnici marcbonnici deleted the fix_bg_cmds branch May 17, 2023 15:24
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.

2 participants