mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Feature
- Protects against interrupt during critical DB commit and sync operations.
This commit is contained in:
parent
ada6e49dab
commit
88abd93e52
3 changed files with 39 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <cmake.h>
|
||||
#include <sstream>
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <Context.h>
|
||||
#include <TLSClient.h>
|
||||
#include <Color.h>
|
||||
|
@ -131,6 +132,15 @@ int CmdSync::execute (std::string& output)
|
|||
out << format (STRING_CMD_SYNC_PROGRESS, connection)
|
||||
<< "\n";
|
||||
|
||||
// Ignore harmful signals.
|
||||
signal (SIGHUP, SIG_IGN);
|
||||
signal (SIGINT, SIG_IGN);
|
||||
signal (SIGKILL, SIG_IGN);
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
signal (SIGTERM, SIG_IGN);
|
||||
signal (SIGUSR1, SIG_IGN);
|
||||
signal (SIGUSR2, SIG_IGN);
|
||||
|
||||
Msg response;
|
||||
if (send (connection, certificate, request, response))
|
||||
{
|
||||
|
@ -270,6 +280,15 @@ int CmdSync::execute (std::string& output)
|
|||
out << "\n";
|
||||
output = out.str ();
|
||||
|
||||
// Restore signal handling.
|
||||
signal (SIGHUP, SIG_DFL);
|
||||
signal (SIGINT, SIG_DFL);
|
||||
signal (SIGKILL, SIG_DFL);
|
||||
signal (SIGPIPE, SIG_DFL);
|
||||
signal (SIGTERM, SIG_DFL);
|
||||
signal (SIGUSR1, SIG_DFL);
|
||||
signal (SIGUSR2, SIG_DFL);
|
||||
|
||||
#else
|
||||
// Without GnuTLS found at compile time, there is no working sync command.
|
||||
throw std::string (STRING_CMD_SYNC_NO_TLS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue