t* dwm + patches URI git clone git://git.codevoid.de/dwm-sdk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 9737fb78c8a2c027b908199ab347cac0bdbd609b DIR parent bae389fbaa1ee3691465ff3e46a013bc67ef52af URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Fri, 8 Jun 2018 22:18:16 +0200 Merge stash (comment in config.h) Diffstat: M selfrestart.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) --- DIR diff --git a/selfrestart.c b/selfrestart.c t@@ -1,6 +1,7 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/sysctl.h> #include <stdio.h> #include <stdlib.h> t@@ -13,9 +14,21 @@ * @return char* the path of the current executable */ char *get_dwm_path(){ + char *path = NULL; +#ifdef __FreeBSD__ + int mib[4]; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PATHNAME; + mib[3] = -1; + char buf[1024]; + size_t cb = sizeof(buf); + sysctl(mib, 4, buf, &cb, NULL, 0); + path = buf; + return path; +#else struct stat s; int r, length, rate = 42; - char *path = NULL; if(lstat("/proc/self/exe", &s) == -1){ perror("lstat:"); t@@ -44,8 +57,8 @@ char *get_dwm_path(){ }while(r >= length); path[r] = '\0'; - return path; +#endif } /**