Add support for macos

This commit is contained in:
Timofey Khoruzhii 2022-10-28 23:34:48 +03:00
parent 5659d5fdaf
commit d892676121
3 changed files with 17 additions and 2 deletions

View file

@ -3,8 +3,8 @@
#include <string>
#include <fstream>
#if !defined(__linux__)
#error Only linux supported
#if !defined(__linux__) && !defined(__APPLE__)
#error Only linux and Macos supported
#endif
namespace cppshell {

View file

@ -2,7 +2,15 @@
#include <cppshell/utils/signals.hpp>
#include <sys/stat.h>
#include <unistd.h>
#if defined(__linux__)
#include <wait.h>
#elif defined(__APPLE__)
#include <sys/wait.h>
#else
#error Supported only on Linux and Mac
#endif
#include <cstdio>
#include <stdexcept>

View file

@ -3,9 +3,12 @@
#include <csignal>
#include <cerrno>
#if !defined(__APPLE__)
thread_local SigpipeState global_state;
#endif
bool IgnoreSigpipe() {
#if !defined(__APPLE__)
sigset_t pending;
sigemptyset(&pending);
sigpending(&pending);
@ -25,9 +28,12 @@ bool IgnoreSigpipe() {
return true;
}
return false;
#endif
return false;
}
void UnignoreSigpipe() {
#if !defined(__APPLE__)
sigset_t pending;
sigemptyset(&pending);
sigpending(&pending);
@ -47,4 +53,5 @@ void UnignoreSigpipe() {
if (global_state.sigpipe_unblock) {
pthread_sigmask(SIG_UNBLOCK, &sigpipe_mask, NULL);
}
#endif
}