2013-09-29から1日間の記事一覧

複数ファイルから書き込む

複数ファイルから書き込む時には、排他ロックを掛ける or 一時ファイルに書き込んでrenameが常套手段。前者については 共有ロックと排他ロックとで調べたので、後者について。 #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include "error.h" #defin</string.h></fcntl.h></unistd.h></stdio.h></stdlib.h>…

複数プロセスからの書き込み - file tableとcurrent offset

同時に複数プロセスから書き込むとファイルが壊れるというが、壊れるというのはどういうことか。 出典: Advanced Programing in the Unix Environment - Figure3.7 異なるプロセスから同じファイルをopenすると、異なるfile tableエントリー(current file o…