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

gatttool timeout handler does not cleanup subprocesses #24

Open
haku opened this issue Nov 24, 2019 · 0 comments
Open

gatttool timeout handler does not cleanup subprocesses #24

haku opened this issue Nov 24, 2019 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@haku
Copy link

haku commented Nov 24, 2019

The timeout handler in connection.wait_for_notification() (and other gatttool functions) does something like:

with Popen(cmd, shell=True, ...) as process:
    try:
        ...
    except TimeoutExpired:
        os.killpg(process.pid, signal.SIGINT)

Because its using shell=True it sends the SIGINT to the /bin/sh process instead of gatttool, which ignores it. The SIGINT needs to be sent directly to the gatttool process. Since the processes are not cleaned up, they build up over time. Often one of them might still have a lock on something, so all subsequent instances of gatttool fail.

This can be easily fixed by removing the shell=True and passing the arguments as a list. e.g.

cmd = ['gatttool', '--device', self._mac, ...]
with Popen(cmd, shell=True, ...) as process:
    ...

Then process.pid will be that of the gatttool process.

@ChristianKuehnel ChristianKuehnel added bug Something isn't working help wanted Extra attention is needed labels Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants