2016-07-27 4 views
1

IDでプロセスを強制終了するためのbashscriptを書いていますが、PIDが変化し続けるので、PIDを稼働させることさえできないようです。どうしてこれなの?グリッピングPIDが変更され続けるのはなぜですか?

Jacks-MBP:~ Knof$ ps aux | grep "firefox" 
Knof    515 0.0 4.3 4822060 723232 ?? U 10:28PM 4:57.15 /Applications/Firefox.app/Contents/MacOS/firefox 
Knof    4489 0.0 0.0 2436888 812 s002 S+ 12:36AM 0:00.00 grep firefox 
Jacks-MBP:~ Knof$ ps aux | grep "firefox" 
Knof    515 0.0 4.3 4822060 723232 ?? U 10:28PM 4:57.15 /Applications/Firefox.app/Contents/MacOS/firefox 
Knof    4491 0.0 0.0 2436888 812 s002 S+ 12:36AM 0:00.00 grep firefox 
Jacks-MBP:~ Knof$ ps aux | grep "firefox" 
Knof    515 0.0 4.3 4822060 723232 ?? U 10:28PM 4:57.15 /Applications/Firefox.app/Contents/MacOS/firefox 
Knof    4493 0.0 0.0 2436888 812 s002 S+ 12:36AM 0:00.00 grep firefox 
Jacks-MBP:~ Knof$ ps aux | grep "firefox" 
Knof    515 0.0 4.3 4822060 723232 ?? U 10:28PM 4:57.15 /Applications/Firefox.app/Contents/MacOS/firefox 
Knof    4495 0.0 0.0 2435864 800 s002 S+ 12:36AM 0:00.00 grep firefox 

答えて

2

たび、あなたはgrepのプロセスを再開している

ps aux | grep "firefox" 

火災。実行中のFirefoxのPIDが /Applications/Firefox.app/Contents/MacOS/firefox

にあることを示すものではありません。

あなたの場合、515は殺すプロセスです。

+0

あなたは数秒で私を倒す... ;-) –

2

プロセスが開始されるたびに、新しい(増分)PIDが割り当てられます。実行可能ファイルとすべての引数が同じであっても。

「firefox」のPIDが、4つのコールすべてで同じであることがわかります。これは、その間に再起動されていないことを示しています。
"grep"のPIDは、コールごとに開始(および終了)されたときに変更されます。

関連する問題