Get current location on Mac too
This commit is contained in:
parent
3d08fcd499
commit
4181e93fbb
16
cbt.h
16
cbt.h
|
@ -156,7 +156,9 @@ void cbt_binary_free(struct cbt_binary bin);
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#ifndef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
#include <libproc.h>
|
||||||
|
#else
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
#endif
|
#endif
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
@ -236,7 +238,11 @@ void cbt__init(int argc, char **argv, const char *source_file) {
|
||||||
|
|
||||||
cbt_log(CBT_LOG_INFO, "Found C Compiler: %s", cbt_cc);
|
cbt_log(CBT_LOG_INFO, "Found C Compiler: %s", cbt_cc);
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
CBT_FAIL(proc_pidpath(getpid(), cbt_location, PATH_MAX) != 0);
|
||||||
|
#else
|
||||||
CBT_FAIL(readlink("/proc/self/exe", cbt_location, PATH_MAX) == -1);
|
CBT_FAIL(readlink("/proc/self/exe", cbt_location, PATH_MAX) == -1);
|
||||||
|
#endif
|
||||||
cbt_log(CBT_LOG_INFO, "Location: %s", cbt_location);
|
cbt_log(CBT_LOG_INFO, "Location: %s", cbt_location);
|
||||||
|
|
||||||
char *cbt_cache_dir = strdup(cbt_location);
|
char *cbt_cache_dir = strdup(cbt_location);
|
||||||
|
@ -514,12 +520,14 @@ int cbt_proc_wait(struct cbt_proc proc) {
|
||||||
return -1000;
|
return -1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1 && !defined(__APPLE__)
|
||||||
static void cbt__line_processor_sig_handler(int signal) { (void)signal; }
|
static void cbt__line_processor_sig_handler(int signal) { (void)signal; }
|
||||||
|
#endif
|
||||||
|
|
||||||
void *cbt__line_processor(void *arg) {
|
void *cbt__line_processor(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
struct timespec timeout = {.tv_sec = 0, .tv_nsec = 100};
|
|
||||||
|
|
||||||
|
#if 1 && !defined(__APPLE__)
|
||||||
sigset_t sigmask;
|
sigset_t sigmask;
|
||||||
sigemptyset(&sigmask);
|
sigemptyset(&sigmask);
|
||||||
sigaddset(&sigmask, SIGUSR1);
|
sigaddset(&sigmask, SIGUSR1);
|
||||||
|
@ -530,11 +538,13 @@ void *cbt__line_processor(void *arg) {
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
|
|
||||||
CBT_FAIL(sigaction(SIGUSR1, &sa, NULL) == -1);
|
CBT_FAIL(sigaction(SIGUSR1, &sa, NULL) == -1);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (cbt_running) {
|
while (cbt_running) {
|
||||||
pthread_mutex_lock(&_cbt__autoproc_mut);
|
pthread_mutex_lock(&_cbt__autoproc_mut);
|
||||||
|
|
||||||
#if 0 && !defined(__APPLE__)
|
#if 1 && !defined(__APPLE__)
|
||||||
|
struct timespec timeout = {.tv_sec = 0, .tv_nsec = 100};
|
||||||
int res = ppoll(cbt__autoproc_fdset.items, cbt__autoproc_fdset.size,
|
int res = ppoll(cbt__autoproc_fdset.items, cbt__autoproc_fdset.size,
|
||||||
&timeout, &sigmask);
|
&timeout, &sigmask);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue