diff options
author | Luke Smith <luke@lukesmith.xyz> | 2020-09-12 09:32:09 -0400 |
---|---|---|
committer | Luke Smith <luke@lukesmith.xyz> | 2020-09-12 09:32:09 -0400 |
commit | cf59ac74328dd8140cc5ab88c6234d2437f4d341 (patch) | |
tree | e194662506b445c3e2824df29d254a9997b41f54 /dwm.c | |
parent | 35e3d2a73c1fd0bc5a2439268fb3ca184d82e95a (diff) | |
parent | 59848a9fdb32bda602bab0d7aea22ff203515ad4 (diff) |
Merge branch 'master' of github.com:LukeSmithxyz/dwm into master
Diffstat (limited to 'dwm.c')
-rw-r--r-- | dwm.c | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -206,7 +206,6 @@ static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); -static int getdwmblockspid(); static int getrootptr(int *x, int *y); static long getstate(Window w); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); @@ -246,7 +245,10 @@ static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); static void sigchld(int unused); +#ifndef __OpenBSD__ +static int getdwmblockspid(); static void sigdwmblocks(const Arg *arg); +#endif static void sighup(int unused); static void sigterm(int unused); static void spawn(const Arg *arg); @@ -1016,6 +1018,7 @@ getatomprop(Client *c, Atom prop) return atom; } +#ifndef __OpenBSD__ int getdwmblockspid() { @@ -1027,6 +1030,7 @@ getdwmblockspid() dwmblockspid = pid; return pid != 0 ? 0 : -1; } +#endif int getrootptr(int *x, int *y) @@ -1908,6 +1912,7 @@ sigterm(int unused) quit(&a); } +#ifndef __OpenBSD__ void sigdwmblocks(const Arg *arg) { @@ -1924,6 +1929,7 @@ sigdwmblocks(const Arg *arg) } } } +#endif void spawn(const Arg *arg) @@ -2406,18 +2412,25 @@ getparentprocess(pid_t p) { unsigned int v = 0; -#ifdef __linux__ +#if defined(__linux__) FILE *f; char buf[256]; snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p); if (!(f = fopen(buf, "r"))) - return 0; + return (pid_t)0; - fscanf(f, "%*u %*s %*c %u", &v); + if (fscanf(f, "%*u %*s %*c %u", (unsigned *)&v) != 1) + v = (pid_t)0; fclose(f); -#endif /* __linux__ */ +#elif defined(__FreeBSD__) + struct kinfo_proc *proc = kinfo_getproc(p); + if (!proc) + return (pid_t)0; + v = proc->ki_ppid; + free(proc); +#endif return (pid_t)v; } |