aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/dwm/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/dwm/util.c')
-rw-r--r--sys/cmd/dwm/util.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/sys/cmd/dwm/util.c b/sys/cmd/dwm/util.c
deleted file mode 100644
index 0db71cc..0000000
--- a/sys/cmd/dwm/util.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include "dwm.h"
-
-void
-fatal(char *fmt, ...) {
- va_list args;
-
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
-
- if(fmt[0] && fmt[strlen(fmt)-1] == ':') {
- fputc(' ', stderr);
- perror(NULL);
- } else {
- fputc('\n', stderr);
- }
-
- exit(1);
-}
-
-void *
-ecalloc(size_t nmemb, size_t size)
-{
- void *p;
-
- if (!(p = calloc(nmemb, size)))
- fatal("calloc:");
- return p;
-}
-
-pid_t
-getparentprocess(pid_t p)
-{
- uint v = 0;
-
-#if defined(__linux__)
- io·Stream *f;
- char buf[256];
- snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p);
-
- if (!(f = fopen(buf, "r")))
- return (pid_t)0;
-
- if (fscanf(f, "%*u %*s %*c %u", (unsigned *)&v) != 1)
- v = (pid_t)0;
- fclose(f);
-#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;
-}
-
-int
-isdescendent(pid_t p, pid_t c)
-{
- while (p != c && c != 0)
- c = getparentprocess(c);
-
- return (int)c;
-}