0
0

More than 1 year has passed since last update.

stop-processコマンドがプロセスが止まっていた原因だった話

Posted at

Windows環境でクロームが重いのでPowerShellで時々

ps -Name *chrome* | stop-process

をよくやる。そしてPythonでも

os.system('powershell -Command "ps -Name *chrome* | stop-process"') 

subprocess.Popen('powershell -Command "ps -Name *chrome* | stop-process"') 

を使っていた。
ところがある日、自動処理が止まっていることを発見。
原因がこのコマンドであることにやっと気付いた。ハマった状況の蓋を開けてみると

次の項目に対して Stop-Process 操作を実行しますか

という確認が出て応答待ち、ペンディング状態だったのだ。

-Forceをつけたコマンドなら待たない。

powershell -Command "ps -Name *chrome* | stop-process -Force"

解決した。
ただ、本当に強制終了したくないプロセスがある場合は気をつけて。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0