blob: 0143d6f6ba23e0b2711132ee29e0fbc1b3e9f889 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/*
* sigterm.c - handler for SIGTERM
* Copyright (c) 2013 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "config.h"
#include <sys/time.h>
#include <event2/event.h>
#include "src/conf.h"
#include "src/util.h"
#include "src/tlsdate.h"
/* On sigterm, grab the system clock and write it before terminating */
void action_sigterm (evutil_socket_t fd, short what, void *arg)
{
struct state *state = arg;
struct timeval tv;
info ("[event:%s] starting graceful shutdown . . .", __func__);
state->exitting = 1;
if (gettimeofday (&tv, NULL))
{
pfatal ("[event:%s] couldn't gettimeofday to exit gracefully", __func__);
}
/* Don't change the last sync_type */
state->last_time = tv.tv_sec;
/* Immediately save and exit. */
trigger_event (state, E_SAVE, -1);
}
|