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

Stop Debugging in a "noDebug" session doesn't kill subprocesses #125

Closed
kenmillar253 opened this issue Mar 9, 2020 · 11 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@kenmillar253
Copy link

VSCode Version: 1.42.1

OS Version: Ubuntu 18.04

Steps to Reproduce:

  • Comment "--noreload" in launch.json
  • Press Ctrl + F5 to run the django process.
  • Click "stop(Shift + F5)" button to stop all django processes.
  • But there is still a process (pid 23069) that has not been closed.
  • And its parent process become 1 from 23064
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Mar 9, 2020
@kenmillar253
Copy link
Author

Sorry, I posted the wrong place

@karthiknadig
Copy link
Member

@kenmillar253 I moved this issue from python extension repo to the debugger repo. This issue should be looked at by the debugger first.

@karthiknadig karthiknadig reopened this Mar 10, 2020
@kenmillar253
Copy link
Author

@kenmillar253 I moved this issue from python extension repo to the debugger repo. This issue should be looked at by the debugger first.
Oh! I misunderstood your meaning, thanks!

@int19h
Copy link
Contributor

int19h commented Mar 10, 2020

This is probably #3

@kenmillar253
Copy link
Author

kenmillar253 commented Mar 11, 2020

This is probably microsoft/debugpy#3

Hi @int19h , I have check this link #3.
Then install debugpy-1.0.0b3, ptvsd-5.0.0a12 and pydevd-1.9.0
The child process is still not auto-kill.

As you mentioned, how can I set launch.json to perform its own cleanup? Which args?

@karthiknadig
Copy link
Member

@kenmillar253 don't install debugpy, ptvsd, or pydevd. This does not matter, since you are using launch configuration, the python extension will pick the debugger for you. Follow the instructions here to get the right debugger:
#59

@kenmillar253
Copy link
Author

kenmillar253 commented Mar 11, 2020

@karthiknadig I have install this dev vsix now.
And when this parameter --noreload is added, there will be 2 processes, all child processes can be closed. But when comment it, there will be 3 processes, only two of them were killed.

@kenmillar253
Copy link
Author

Screenshot from 2020-03-11 14-20-24

@int19h
Copy link
Contributor

int19h commented Mar 11, 2020

If you do import ptvsd; print(ptvsd.__version__) at the beginning of your code, what does it print?

@kenmillar253
Copy link
Author

@int19h It print 5.0.0a12

Screenshot from 2020-03-11 14-31-46

There is one child process not closed with its parent pid become 1
Screenshot from 2020-03-11 14-30-24

@int19h
Copy link
Contributor

int19h commented Mar 24, 2020

Mystery solved - the reason why I couldn't repro is because I didn't notice that you were using Ctrl+F5 (i.e. running without debugging).

The problem is that when we're not debugging, we're also not able to detect subprocesses. So when you stop the no-debug session, we kill the parent Django process, but not the child process that it had spawned.

We'll need to add some special cleanup to the launcher to kill the entire process tree in this scenario.

@int19h int19h transferred this issue from microsoft/ptvsd Apr 16, 2020
@int19h int19h added the bug Something isn't working label May 2, 2020
@int19h int19h assigned int19h and unassigned fabioz Aug 6, 2020
@int19h int19h changed the title vscode didn't close all django processes when comment "--noreload" Stop Debugging doesn't kill subprocesses Aug 6, 2020
@int19h int19h changed the title Stop Debugging doesn't kill subprocesses Stop Debugging in a "noDebug" session doesn't kill subprocesses Aug 6, 2020
int19h added a commit to int19h/debugpy that referenced this issue Aug 7, 2020
… subprocesses

On Win32, use job objects to tie the lifetime of debuggee and its subprocesses to that of the launcher process.

On POSIX, run the launcher and its children in a separate process group (PGID), and kill the entire group when launcher exits.
int19h added a commit to int19h/debugpy that referenced this issue Aug 10, 2020
… subprocesses

On Windows, run the debuggee in a separate Win32 job, and terminate the job when launcher exits.

On POSIX, run the debuggee in a separate process group (PGID), and kill the entire group when launcher exits.
int19h added a commit to int19h/debugpy that referenced this issue Aug 10, 2020
… subprocesses

On Windows, run the debuggee in a separate Win32 job, and terminate the job when launcher exits.

On POSIX, run the debuggee in a separate process group (PGID), and kill the entire group when launcher exits.
int19h added a commit to int19h/debugpy that referenced this issue Aug 10, 2020
… subprocesses

On Windows, run the debuggee in a separate Win32 job, and terminate the job when launcher exits.

On POSIX, run the debuggee in a separate process group (PGID), and kill the entire group when launcher exits.

Improve process tree autokill tests to actually check whether the child process has exited.
@int19h int19h closed this as completed in 57ec4c4 Aug 11, 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
Projects
None yet
Development

No branches or pull requests

4 participants