~mvo/apt/libudev-dlopen

« back to all changes in this revision

Viewing changes to apt-pkg/deb/dpkgpm.cc

  • Committer: Michael Vogt
  • Date: 2009-06-17 08:15:51 UTC
  • Revision ID: michael.vogt@ubuntu.com-20090617081551-57he6ab431ewjna7
* apt-pkg/deb/dpkgpm.cc:
  - add Dpkg::UseIoNice boolean option to run dpkg with ionice -c3
    (off by default)

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
  };
75
75
}
76
76
 
 
77
/* helper function to ionice the given PID 
 
78
 
 
79
 there is no C header for ionice yet - just the syscall interface
 
80
 so we use the binary from util-linux
 
81
*/
 
82
static bool
 
83
ionice(int PID)
 
84
{
 
85
   if (!FileExists("/usr/bin/ionice"))
 
86
      return false;
 
87
   pid_t Process = ExecFork();      
 
88
   if (Process == 0)
 
89
   {
 
90
      char buf[32];
 
91
      snprintf(buf, sizeof(buf), "-p%d", PID);
 
92
      const char *Args[4];
 
93
      Args[0] = "/usr/bin/ionice";
 
94
      Args[1] = "-c3";
 
95
      Args[2] = buf;
 
96
      Args[3] = 0;
 
97
      execv(Args[0], (char **)Args);
 
98
   }
 
99
   return ExecWait(Process, "ionice");
 
100
}
 
101
 
77
102
// DPkgPM::pkgDPkgPM - Constructor                                      /*{{{*/
78
103
// ---------------------------------------------------------------------
79
104
/* */
850
875
               _exit(100);
851
876
         }
852
877
 
853
 
 
854
878
         /* No Job Control Stop Env is a magic dpkg var that prevents it
855
879
            from using sigstop */
856
880
         putenv((char *)"DPKG_NO_TSTP=yes");
859
883
         _exit(100);
860
884
      }      
861
885
 
 
886
      // apply ionice
 
887
      if (_config->FindB("DPkg::UseIoNice", false) == true)
 
888
         ionice(Child);
 
889
 
862
890
      // clear the Keep-Fd again
863
891
      _config->Clear("APT::Keep-Fds",fd[1]);
864
892