]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-sources.cc
flock() the file edited in edit-sources
[apt.git] / apt-private / private-sources.cc
index 65706e785fcdf451caa214e858fa903e0f900ee5..41cf6b31323cf912792fbbd52f52cf41f81d8c8e 100644 (file)
@@ -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(