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

Hapless doesn't seem to actually kill the background task #17

Open
nathan-fiscaletti opened this issue Nov 15, 2022 · 4 comments
Open

Comments

@nathan-fiscaletti
Copy link

Step 1: Create a background task using hapless.

image

Step 2: Hapless shows it as running.

image

Step 3: Checking the processes with ps shows three distinct processes for the task. The pid reported by hapless seems to be the second in the list from ps.

image

When I attempt to kill the task all but the last of the processes from ps seem to be killed, which leaves the task running even though hapless reports that it isn't running.

image

@bmwant
Copy link
Owner

bmwant commented Nov 16, 2022

Hey @nathan-fiscaletti, could you provide additional information:

  1. hapless version: hap --version
  2. your OS
  3. content of the script if possible. If not I would like to know whether it spawns/forks/multiprocess etc within the script

@bmwant
Copy link
Owner

bmwant commented Nov 16, 2022

Only two processes should be created:
one main for the hapless itself
second one for the process you actually need to execute
You can check your parent pid also by invoking hap status -v 1 or using something like pstree to see whether you third process is related in any way to previous two
Screen Shot 2022-11-16 at 1 56 30 PM

@bmwant
Copy link
Owner

bmwant commented Nov 16, 2022

ok, I found the issue and it is related to the shell=True parameter and extra process being created for the shell itself (tried on Ubuntu 20.04). I have created a fix to kill child process as well and will release new version soon.

In a future release I do also plan to skip shell spawning altogether and just provide current environment directly to the subprocess.

@bmwant
Copy link
Owner

bmwant commented Nov 16, 2022

In a meanwhile you can test the fix by yourself by installing latest development branch

$ pip install git+https://github.com/bmwant/hapless.git

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

No branches or pull requests

2 participants