瀏覽代碼

flock() the file edited in edit-sources

Michael Vogt 12 年之前
父節點
當前提交
c189f87d57
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      apt-private/private-sources.cc

+ 5 - 0
apt-private/private-sources.cc

@@ -32,6 +32,10 @@ bool EditSources(CommandLine &CmdL)
    if (FileExists(sourceslist))
        before.FromFile(sourceslist);
 
+   int lockfd = GetLock(sourceslist);
+   if (lockfd < 0)
+      return false;
+      
    do {
       EditFileInSensibleEditor(sourceslist);
       _error->PushToStack();
@@ -46,6 +50,7 @@ bool EditSources(CommandLine &CmdL)
       }
       _error->RevertToStack();
    } while (res == false);
+   close(lockfd);
 
    if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
       strprintf(