blob: 7176f052cbb50399e88db8793506de94b98bf52d [file] [log] [blame]
Dmitriy Ivanovf57874d2014-10-07 13:43:23 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifdef HAVE_ANDROID_OS
18#include <android/log.h>
19#else
20#include <stdarg.h>
21#include <iostream>
22#endif
23
24#include <stdlib.h>
25
26#include "sigchain.h"
27
28static void log(const char* format, ...) {
29 char buf[256];
30 va_list ap;
31 va_start(ap, format);
32 vsnprintf(buf, sizeof(buf), format, ap);
33#ifdef HAVE_ANDROID_OS
34 __android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
35#else
36 std::cout << buf << "\n";
37#endif
38 va_end(ap);
39}
40
41extern "C" void ClaimSignalChain(int signal, struct sigaction* oldaction) {
42 log("ClaimSignalChain is not exported by the main executable.");
43 abort();
44}
45
46extern "C" void UnclaimSignalChain(int signal) {
47 log("UnclaimSignalChain is not exported by the main executable.");
48 abort();
49}
50
51extern "C" void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context) {
52 log("InvokeUserSignalHandler is not exported by the main executable.");
53 abort();
54}
55
56extern "C" void InitializeSignalChain() {
57 log("InitializeSignalChain is not exported by the main executable.");
58 abort();
59}