X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/2aefd2c272c36d0a0761ef0d715f75321d8014af..f8ac1720a94468d1384e88a57729e6d9801b56fd:/apt-pkg/deb/dpkgpm.cc diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index ea64ef089..61c48dcbb 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: dpkgpm.cc,v 1.26 2003/04/27 03:02:40 doogie Exp $ +// $Id: dpkgpm.cc,v 1.28 2004/01/27 02:25:01 mdz Exp $ /* ###################################################################### DPKG Package Manager - Provide an interface to dpkg @@ -326,10 +326,10 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) // DPkgPM::Go - Run the sequence /*{{{*/ // --------------------------------------------------------------------- /* This globs the operations and calls dpkg */ -bool pkgDPkgPM::Go() +bool pkgDPkgPM::Go(int status_fd) { - unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",350); - unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",8192); + unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024); + unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024); if (RunScripts("DPkg::Pre-Invoke") == false) return false; @@ -367,6 +367,17 @@ bool pkgDPkgPM::Go() } } + // if we got a status_fd argument, we pass it to apt + char status_fd_buf[20]; + if(status_fd > 0) + { + Args[n++] = "--status-fd"; + Size += strlen(Args[n-1]); + snprintf(status_fd_buf,20,"%i",status_fd); + Args[n++] = status_fd_buf; + Size += strlen(Args[n-1]); + } + switch (I->Op) { case Item::Remove: @@ -436,11 +447,15 @@ bool pkgDPkgPM::Go() it forks scripts. What happens is that when you hit ctrl-c it sends it to all processes in the group. Since dpkg ignores the signal it doesn't die but we do! So we must also ignore it */ - signal(SIGQUIT,SIG_IGN); - signal(SIGINT,SIG_IGN); + sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); + sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN); // Fork dpkg - pid_t Child = ExecFork(); + pid_t Child; + if(status_fd > 0) + Child = ExecFork(status_fd); + else + Child = ExecFork(); // This is the child if (Child == 0) @@ -448,7 +463,7 @@ bool pkgDPkgPM::Go() if (chdir(_config->FindDir("DPkg::Run-Directory","/").c_str()) != 0) _exit(100); - if (_config->FindB("DPkg::FlushSTDIN",true) == true) + if (_config->FindB("DPkg::FlushSTDIN",true) == true && isatty(STDIN_FILENO)) { int Flags,dummy; if ((Flags = fcntl(STDIN_FILENO,F_GETFL,dummy)) < 0) @@ -479,12 +494,16 @@ bool pkgDPkgPM::Go() if (errno == EINTR) continue; RunScripts("DPkg::Post-Invoke"); + + // Restore sig int/quit + signal(SIGQUIT,old_SIGQUIT); + signal(SIGINT,old_SIGINT); return _error->Errno("waitpid","Couldn't wait for subprocess"); } // Restore sig int/quit - signal(SIGQUIT,SIG_DFL); - signal(SIGINT,SIG_DFL); + signal(SIGQUIT,old_SIGQUIT); + signal(SIGINT,old_SIGINT); // Check for an error code. if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)