blob: f511ab06410edb138a0fe056d3cfdf67634bc532 [file] [log] [blame]
// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef STARBOARD_SHARED_SIGNAL_SIGNAL_INTERNAL_H_
#define STARBOARD_SHARED_SIGNAL_SIGNAL_INTERNAL_H_
#include <signal.h>
#include "starboard/log.h"
#include "starboard/shared/internal_only.h"
namespace starboard {
namespace shared {
namespace signal {
inline const char* GetSignalName(int signal_id) {
switch (signal_id) {
case SIGABRT:
return "SIGABRT";
case SIGCONT:
return "SIGCONT";
case SIGFPE:
return "SIGFPE";
case SIGILL:
return "SIGILL";
case SIGINT:
return "SIGINT";
case SIGSEGV:
return "SIGSEGV";
case SIGTSTP:
return "SIGTSTP";
case SIGTERM:
return "SIGTERM";
default:
return "UNKNOWN SIGNAL";
}
}
inline void LogSignalCaught(int signal_id) {
const char* signal_name = GetSignalName(signal_id);
SbLogRawFormatF("\nCaught signal: %s (%d)\n", signal_name, signal_id);
SbLogFlush();
}
typedef void (*SignalHandlerFunction)(int);
} // namespace signal
} // namespace shared
} // namespace starboard
#endif // STARBOARD_SHARED_SIGNAL_SIGNAL_INTERNAL_H_