-#ifdef LINUX
- struct stat statbuf;
- char procbuf[512];
- (void)snprintf(procbuf, sizeof(procbuf), "/proc/%ld", strtol(pidbuf, NULL, 10));
- return (stat(procbuf, &statbuf) >= 0);
-#else
- /* TODO: correctly check for NetBSD. Evaluate if this runs on OpenBSD/FreeBSD */
- struct kinfo_proc info;
- size_t length = sizeof(struct kinfo_proc);
- int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, strtol(pidbuf, NULL, 10) };
- if (sysctl(mib, 4, &info, &length, NULL, 0) < 0)
- return false;
- return (length != 0);
-#endif