62 static const char *myEname = 0;
70 if (myEname)
return myEname;
74#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
77 if ((epLen = readlink(
"/proc/self/exe", epBuff,
sizeof(epBuff)-1)) > 0)
79 myEname = strdup(epBuff);
83#elif defined(__APPLE__)
85 uint32_t epLen =
sizeof(epBuff)-1;
86 if (!_NSGetExecutablePath(epBuff, &epLen))
88 myEname = strdup(epBuff);
92#elif defined(__solaris__)
93 {
const char *epBuff = getexecname();
95 {
if (*epBuff ==
'/') myEname = strdup(epBuff);
96 else {
char *ename, *cwd = getcwd(0, MAXPATHLEN);
97 ename = (
char *)malloc(strlen(cwd)+1+strlen(epBuff)+1);
98 sprintf(ename,
"%s/%s", cwd, epBuff);
120 return snprintf(buff, blen,
"%s",
"windows");
122 struct utsname uInfo;
126 if (uname(&uInfo) < 0)
return snprintf(buff, blen,
"%s",
"unknown OS");
131#if defined(__linux__)
132 return snprintf(buff, blen,
"%s %s", uInfo.sysname, uInfo.release);
133#elif defined(__APPLE__) || defined(__FreeBSD__) || (defined(__FreeBSD__) || defined(__GLIBC__))
134 return snprintf(buff, blen,
"%s %s %s", uInfo.sysname, uInfo.release,
137 return snprintf(buff, blen,
"%s %s %s %s", uInfo.sysname, uInfo.release,
138 uInfo.version, uInfo.machine);
194 signal(SIGPIPE, SIG_IGN);
196#ifdef ENABLE_COVERAGE
198 signal(SIGTERM, [](
int) { __gcov_dump(); _exit(EXIT_SUCCESS); });
204 sigaddset(&myset, SIGPIPE);
205 sigaddset(&myset, SIGCHLD);
210 sigaddset(&myset, SIGRTMAX);
211 sigaddset(&myset, SIGRTMAX-1);
216 return pthread_sigmask(SIG_BLOCK, &myset, NULL) == 0;