[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FDclone-users:00492] .fd_history was lost



 2.07b から 2.08b に上げたところ、コマンド履歴ファイルが
truncate されてしまう現象に遭遇しました。おそらく 2.07c の
変更が原因だと思います。

 ホームディレクトリを NFS マウントして運用しているのですが、
この環境ではファイルのロックがサポートされていないために、
shell.c:savehistory() の Xfopen(file, "w") → lockfile() の
ところで失敗し、そのまま Xfclose() されて ~/.fd_history が
空っぽになってしまいます。

 対策としては、

1. 別にロックファイルを作る
2. open(2) の O_EXLOCK でアトミックにロックする
3. 追記モード(a, a+, r+)でオープンして truncate させない

といったところでしょうか。

 zsh は 1, pdksh は 3 を採用しているようです。

 csh, tcsh, ash, bash (libreadline) などはファイルロック自体
していないようでした。同じユーザで対話シェルを同時に起動または
終了するというケースはまれと見たからかもしれません。

-- 
                     /
                    /__  __            Akinori.org / MUSHA.org
                   / )  )  ) )  /     FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ /  ( (__(  @ iDaemons.org / and.or.jp

"Different eyes see different things,
    Different hearts beat on different strings --
       But there are times for you and me when all such things agree"