summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-private/private-main.cc9
-rw-r--r--apt-private/private-main.h1
-rw-r--r--apt-private/private-output.cc21
-rw-r--r--cmdline/apt-get.cc22
-rw-r--r--cmdline/apt.cc4
5 files changed, 38 insertions, 19 deletions
diff --git a/apt-private/private-main.cc b/apt-private/private-main.cc
index 2d3965172..668b1733a 100644
--- a/apt-private/private-main.cc
+++ b/apt-private/private-main.cc
@@ -8,9 +8,18 @@
#include <iostream>
#include <string.h>
#include <unistd.h>
+#include <signal.h>
#include <apti18n.h>
+
+void InitSignals()
+{
+ // Setup the signals
+ signal(SIGPIPE,SIG_IGN);
+}
+
+
void CheckSimulateMode(CommandLine &CmdL)
{
// simulate user-friendly if apt-get has no root privileges
diff --git a/apt-private/private-main.h b/apt-private/private-main.h
index 23d4aca68..a03bf4441 100644
--- a/apt-private/private-main.h
+++ b/apt-private/private-main.h
@@ -6,5 +6,6 @@
class CommandLine;
APT_PUBLIC void CheckSimulateMode(CommandLine &CmdL);
+APT_PUBLIC void InitSignals();
#endif
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 757999167..7f3eef6c2 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -22,6 +22,7 @@
#include <iostream>
#include <langinfo.h>
#include <unistd.h>
+#include <signal.h>
#include <apti18n.h>
/*}}}*/
@@ -32,8 +33,24 @@ std::ostream c0out(0);
std::ostream c1out(0);
std::ostream c2out(0);
std::ofstream devnull("/dev/null");
+
+
unsigned int ScreenWidth = 80 - 1; /* - 1 for the cursor */
+// SigWinch - Window size change signal handler /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+static void SigWinch(int)
+{
+ // Riped from GNU ls
+#ifdef TIOCGWINSZ
+ struct winsize ws;
+
+ if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
+ ScreenWidth = ws.ws_col - 1;
+#endif
+}
+ /*}}}*/
bool InitOutput() /*{{{*/
{
if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
@@ -47,6 +64,10 @@ bool InitOutput() /*{{{*/
if (_config->FindI("quiet",0) > 1)
c1out.rdbuf(devnull.rdbuf());
+ // deal with window size changes
+ signal(SIGWINCH,SigWinch);
+ SigWinch(0);
+
if(!isatty(1))
{
_config->Set("APT::Color", "false");
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index caf69da2a..566103f8c 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1666,20 +1666,6 @@ static bool ShowHelp(CommandLine &)
return true;
}
/*}}}*/
-// SigWinch - Window size change signal handler /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static void SigWinch(int)
-{
- // Riped from GNU ls
-#ifdef TIOCGWINSZ
- struct winsize ws;
-
- if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col >= 5)
- ScreenWidth = ws.ws_col - 1;
-#endif
-}
- /*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate},
@@ -1734,14 +1720,12 @@ int main(int argc,const char *argv[]) /*{{{*/
// see if we are in simulate mode
CheckSimulateMode(CmdL);
+ // Init the signals
+ InitSignals();
+
// Setup the output streams
InitOutput();
- // Setup the signals
- signal(SIGPIPE,SIG_IGN);
- signal(SIGWINCH,SigWinch);
- SigWinch(0);
-
// Match the operation
CmdL.DispatchArg(Cmds);
diff --git a/cmdline/apt.cc b/cmdline/apt.cc
index 4813861a4..72086af14 100644
--- a/cmdline/apt.cc
+++ b/cmdline/apt.cc
@@ -96,6 +96,10 @@ int main(int argc, const char *argv[]) /*{{{*/
std::vector<CommandLine::Args> Args = getCommandArgs("apt", CommandLine::GetCommand(Cmds, argc, argv));
+ // Init the signals
+ InitSignals();
+
+ // Init the output
InitOutput();
// Set up gettext support