Posix record locking is supported on nearly all unix - like platforms it s mandated by posix . 1 , it can lock portions of a file not just a whole file , and it can handle the difference between read locks and write locks 采用posix記錄鎖的理由有很多: posix記錄鎖在幾乎所有的類unix平臺(tái)上都獲得了支持(它得到了posix . 1的授權(quán)) ,它可以鎖定文件的一部分(而不是只會(huì)鎖定整個(gè)文件) ,而且它可以區(qū)別處理讀鎖和寫鎖的不同之處。
Windows versions used ini files , then moved to a binary and unified registry ; eariler versions of mac os had resource forks in the file system and a desktop file for its finder ; linux and other unix - like systems typically used dotted , hidden files in home directories , with configuration detailed in dozens of incompatible ways between window managers and applications Windows版本使用ini文件,后來改為二進(jìn)制的(也是統(tǒng)一的)注冊表;早期版本的mac os在文件系統(tǒng)中有資源叉和供finder使用的桌面文件; linux和其他類unix系統(tǒng)通常使用主目錄中分散的、隱藏的文件,窗體管理工具和應(yīng)用程序之間的詳細(xì)配置有多種互不兼容的方式。
Programs sometimes leave behind junk temporary files , so most unix - like systems automatically delete old temporary files in the special directories tmp and var tmp the program " tmpwatch " does this , and some programs automatically remove files from special temporary file directories 程序有時(shí)會(huì)留下一些沒用的臨時(shí)文件,所以,大部分類unix系統(tǒng)會(huì)自動(dòng)刪除特定目錄/ tmp和/ var / tmp下的原有臨時(shí)文件( “ tmpwatch ”程序可以完成這項(xiàng)任務(wù)) ,一些程序會(huì)“自動(dòng)”刪除它們所使用的特定臨時(shí)目錄下的文件。
This article shows you how to handle common race conditions on unix - like systems , including how to create lock files correctly , alternatives to lock files , how to handle the file system , and how to handle shared directories - and , in particular , how to correctly create temporary files in the tmp directory 本文向您展示了如何在類unix ( unix - like )系統(tǒng)中處理常見的競爭條件,包括如何正確地創(chuàng)建鎖文件、鎖文件的替代者,如何處理文件系統(tǒng),以及如何處理共享目錄(特別是如何在/ tmp目錄下正確創(chuàng)建臨時(shí)目錄) 。