inotifywait(1) で偽Plan9な感じにFirefoxを休ませる
元ネタ:
- http://peta.okechan.net/blog/archives/967 Macで重いバックグラウンドアプリケーションを劇的に軽くするPythonスクリプト « 日曜研究室
偽Plan9のセットアップ:
#! /bin/sh cd /dev/shm mkdir stopper cd stopper inotifywait -m -e modify --format %f . | \ while read line; do if grep -q 1 $line; then kill -STOP $line else kill -CONT $line rm $line fi done
実行にはこう
$ ps x|grep [f]irefox 24768 ? Sl 85:08 /usr/lib/iceweasel/firefox-bin $ echo 1 > /dev/shm/stopper/24768 $ echo 0 > /dev/shm/stopper/24768
このように inotifywait(1)
を使えばユーザからのコマンドをファイルシステム上で受けとることができる.課題はユーザにファイルシステムとして情報を見せることだ(/proc
みたいに).そっちはFUSE使わないと駄目かなー.open(2) をトラップしてNICE値の低いプロセスで先を越して中を書き込むとか妄想はしてるんだけど.Debian上川さんが pbuilder
作ったときの資料とか読むとなかなかそうもいかないぽい.