aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/signalhandler/victim.cpp
blob: e28739a393d74a043dda15e399b1653d22e64f8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/util/signalhandler.h>
#include <cstdio>
#include <unistd.h>

using vespalib::SignalHandler;

int main(int argc, char **argv) {
    (void) argc;
    (void) argv;
    SignalHandler::TERM.hook();
    kill(getpid(), SIGTERM);
    if (SignalHandler::TERM.check()) {
        fprintf(stdout, "GOT TERM\n");
        fflush(stdout);
    }
    SignalHandler::TERM.unhook();
    kill(getpid(), SIGTERM);
    fprintf(stdout, "SURVIVED TERM\n");
    fflush(stdout);
    return 0;
}