]
トップ «前の日記(2008-09-10) 最新 次の日記(2008-09-12)» 編集

Yukiharu YABUKI の tDiary



このtDiaryを検索します。

2008-09-11 [長年日記]

_ pthread を使う上で陥りがちな罠

bashのulimit -s でバイトサイズを適切なサイズにしておかないとデフォルト値は8Mなので、ドンドンと仮想メモリを食っていくプログラムができやすい。

_ inotify-tools

inotifyを使って、「待ち」を作りたい場合は、inotifywait を "Watch"をさせたい場合は、inotifywatchを。詳細は man inotifywait および man inotifywatch を行うこと。

Ernalda:~# aptitude install inotify-tools
Reading package lists... Done
Building dependency tree... Done
Reading extended state information
Initializing package states... Done
Writing extended state information... Done
Reading task descriptions... Done
Building tag database... Done
The following NEW packages will be installed:
  inotify-tools
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 78.3kB of archives. After unpacking 442kB will be used.
Writing extended state information... Done
Get:1 http://security.debian.org stable/updates/main inotify-tools 3.3-2 [78.3kB]
Fetched 78.3kB in 8s (8721B/s)
Selecting previously deselected package inotify-tools.
(Reading database ... 270755 files and directories currently installed.)
Unpacking inotify-tools (from .../inotify-tools_3.3-2_i386.deb) ...
Setting up inotify-tools (3.3-2) ...
inotifywait実験

shell scirptなどでinotifyを使って、Daemonもどきなファイル監視スクリプトを作りたい場合に役立つ。

端末Aで inotifywait を実行すると

yabuki@Ernalda:/tmp$ inotifywait -e modify hoge
Setting up watches.
Watches established.
のように「待ち」に入る。そこで、端末Bから、echo "fuga" > /tmp/hoge とすると、
hoge MODIFY

という表示を出して、waitから抜けてくる。