Skip to content

Commit

Permalink
Re-add FreeBSD support.
Browse files Browse the repository at this point in the history
  • Loading branch information
deadpixi committed May 24, 2017
1 parent 22c09a2 commit 42a798c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2169,18 +2169,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;
}

Expand Down

0 comments on commit 42a798c

Please sign in to comment.