• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include <stdio.h>
26 
27 #include "sigchain.h"
28 
log(const char * format,...)29 static void log(const char* format, ...) {
30   char buf[256];
31   va_list ap;
32   va_start(ap, format);
33   vsnprintf(buf, sizeof(buf), format, ap);
34 #ifdef HAVE_ANDROID_OS
35   __android_log_write(ANDROID_LOG_ERROR, "libsigchain", buf);
36 #else
37   std::cout << buf << "\n";
38 #endif
39   va_end(ap);
40 }
41 
ClaimSignalChain(int signal,struct sigaction * oldaction)42 extern "C" void ClaimSignalChain(int signal, struct sigaction* oldaction) {
43   log("ClaimSignalChain is not exported by the main executable.");
44   abort();
45 }
46 
EnsureFrontOfChain(int signal,struct sigaction * expected_action)47 extern "C" void EnsureFrontOfChain(int signal, struct sigaction* expected_action) {
48   log("EnsureFrontOfChain is not exported by the main executable.");
49   abort();
50 }
51 
UnclaimSignalChain(int signal)52 extern "C" void UnclaimSignalChain(int signal) {
53   log("UnclaimSignalChain is not exported by the main executable.");
54   abort();
55 }
56 
InvokeUserSignalHandler(int sig,siginfo_t * info,void * context)57 extern "C" void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context) {
58   log("InvokeUserSignalHandler is not exported by the main executable.");
59   abort();
60 }
61 
InitializeSignalChain()62 extern "C" void InitializeSignalChain() {
63   log("InitializeSignalChain is not exported by the main executable.");
64   abort();
65 }
66