Skip to content

Debugging as sudo fails to terminate the debugger when you stop #92

@jimbobbennett

Description

@jimbobbennett

Environment data

  • PTVSD version: 2020.3.71113
  • OS and version: macOS 10.15.3 using remote ssh into a Raspberry Pi 3B Raspbian Buster
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3
  • Using VS Code or Visual Studio: VS Code

Actual behavior

When debugging as sudo, when the debugger is stopped the process still runs as the termination command fails. The terminal returns to the command prompt, but the process is running in the background.

Expected behavior

When the debugger is stopped, the process should stop.

Steps to reproduce:

  1. Use this python code:

    import asyncio
    
    async def main():
        async def main_loop():
            while True:
                print('looping')
                await asyncio.sleep(1)
    
        await main_loop()
    
    if __name__ == '__main__':
        asyncio.run(main())
  2. Debug the local file using the option "sudo": true in the launch.json

  3. It will run and output looping

  4. Stop the debugger. You will see an exception:

    E+00006.483: Failed to kill Debuggee[PID=2134]
             
                 Traceback (most recent call last):
                   File "/home/pi/.vscode-server/extensions/ms-python.python-2020.3.71113/pythonFiles/lib/python/debugpy/wheels/debugpy/launcher/../../debugpy/launcher/debuggee.py", line 104, in kill
                 process.kill()
                   File "/usr/lib/python3.7/subprocess.py", line 1756, in kill
                     self.send_signal(signal.SIGKILL)
                   File "/usr/lib/python3.7/subprocess.py", line 1746, in send_signal
                     os.kill(self.pid, sig)
                 PermissionError: [Errno 1] Operation not permitted
             
                 Stack where logged:
                   File "/home/pi/.vscode-server/extensions/ms-python.python-2020.3.71113/pythonFiles/lib/python/debugpy/wheels/debugpy/launcher/../../debugpy/launcher/debuggee.py", line 106, in kill
                     log.swallow_exception("Failed to kill {0}", describe())
                   File "/home/pi/.vscode-server/extensions/ms-python.python-2020.3.71113/pythonFiles/lib/python/debugpy/wheels/debugpy/launcher/../../debugpy/common/log.py", line 215, in swallow_exception
                     _exception(format_string, *args, **kwargs)
  5. The output will keep showing looping

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions