benfred / py-spy

Sampling profiler for Python programs
MIT License
12.14k stars 400 forks source link

ctrl-c'ing py-spy suspends attached process #587

Open ezyang opened 1 year ago

ezyang commented 1 year ago

I notice that when I py-spy top -p PID, and then ctrl-c py-spy, this also suspends the attached process. (It can be resumed with 'fg' in its terminal). It would be better if it didn't do this.

benfred commented 1 year ago

@ezyang - this shouldn't be happening, we have a control-c handler https://github.com/benfred/py-spy/blob/a83887268f06b8735b5b115617f3632220d7a090/src/main.rs#L196 that should detect the control-c and then trigger a graceful cleanup (including resuming any suspended processes).

What OS are you running this on? Also what version of py-spy and python are you using?

ezyang commented 1 year ago

Linux

(/home/ezyang/local/a/pytorch-env) [ezyang@devgpu019.ftw1 ~/local/a/lit-llama (main)]$ py-spy --version
py-spy 0.3.14
(/home/ezyang/local/a/pytorch-env) [ezyang@devgpu019.ftw1 ~/local/a/lit-llama (main)]$ python --version
Python 3.10.11