Explorar el Código

flock() the file edited in edit-sources

Michael Vogt hace 12 años
padre
commit
c189f87d57
Se han modificado 1 ficheros con 5 adiciones y 0 borrados
  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))
    if (FileExists(sourceslist))
        before.FromFile(sourceslist);
        before.FromFile(sourceslist);
 
 
+   int lockfd = GetLock(sourceslist);
+   if (lockfd < 0)
+      return false;
+      
    do {
    do {
       EditFileInSensibleEditor(sourceslist);
       EditFileInSensibleEditor(sourceslist);
       _error->PushToStack();
       _error->PushToStack();
@@ -46,6 +50,7 @@ bool EditSources(CommandLine &CmdL)
       }
       }
       _error->RevertToStack();
       _error->RevertToStack();
    } while (res == false);
    } while (res == false);
+   close(lockfd);
 
 
    if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
    if (FileExists(sourceslist) && !before.VerifyFile(sourceslist)) {
       strprintf(
       strprintf(