diff --git a/src/lib/protocol/Download.cc b/src/lib/protocol/Download.cc index 1959dd3..e763e94 100644 --- a/src/lib/protocol/Download.cc +++ b/src/lib/protocol/Download.cc @@ -18,6 +18,7 @@ */ #include "Download.hh" +#include "../util/SignalHandler.hh" #include @@ -57,6 +58,9 @@ Download::~Download( ) std::string Download::Finish() const { + // Unregister the signal + SignalHandler::GetInstance().UnregisterSignal( SIGINT ) ; + std::string result ; // get the checksum and return it ; diff --git a/src/lib/protocol/HTTP.cc b/src/lib/protocol/HTTP.cc index 847a689..44a7b61 100644 --- a/src/lib/protocol/HTTP.cc +++ b/src/lib/protocol/HTTP.cc @@ -20,6 +20,7 @@ #include "HTTP.hh" #include "Download.hh" +#include "../util/SignalHandler.hh" // dependent libraries #include @@ -109,6 +110,14 @@ void DoCurl( CURL *curl ) } } +// Callback for SIGINT +void CallbackInt( int ) +{ + // TODO: instead of just disabling the signal, clean up the environment + // and exit gracefully + std::cout << " Signal disabled while downloading file..\n"; +} + } // end of local namespace namespace gr { namespace http { @@ -139,6 +148,9 @@ void GetFile( const std::string& filename, const Headers& hdr ) { + // Register the callback + SignalHandler::GetInstance().RegisterSignal( SIGINT, &CallbackInt ) ; + Download dl( filename, Download::NoChecksum() ) ; CURL *curl = InitCurl( url, 0, hdr ) ;