【发布时间】:2017-06-22 07:11:41
【问题描述】:
我运行一个 python 脚本:
python main.py
好的,它在无限 while 循环中运行。我怎样才能停止一个(实际)会话腻子?
Ctrl + c 不工作。
只关闭腻子,再次打开并杀死进程帮助我。
感谢您的帮助。
【问题讨论】:
我运行一个 python 脚本:
python main.py
好的,它在无限 while 循环中运行。我怎样才能停止一个(实际)会话腻子?
Ctrl + c 不工作。
只关闭腻子,再次打开并杀死进程帮助我。
感谢您的帮助。
【问题讨论】:
您的代码是否使用信号模块捕获 SIGINT?或者它是通过代码中某处的 KeyboardInterrupt 捕获的(如果没有我的代码很难说)?
您可以做的一件事是在屏幕之类的虚拟终端中启动您的进程 - 您可以通过 CTRL-A D 退出,然后在外面终止进程。
【讨论】:
试试 Ctrl + z; bg 然后杀死。
yalca:~ farax$ python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
ctrl + z
[1]+ Stopped python
yalca:~ farax$ bg
[1]+ python &
[1]+ Stopped python
yalca:~ farax$ jobs
[1]+ Stopped python
yalca:~ farax$ kill %1
[1]+ Terminated: 15 python
yalca:~ farax$
【讨论】: