summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-09-15 22:25:27 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-09-15 22:25:27 +0200
commit0235a84ef286db5c97239615ae525ce973641941 (patch)
treeeed9e2c2b39249ada5353a841f8717894bf236b0 /util.c
parentnew colorscheme (16-bit compliant) (diff)
downloaddwm-0235a84ef286db5c97239615ae525ce973641941.tar.gz
dwm-0235a84ef286db5c97239615ae525ce973641941.zip
micromizing dwm step 1
Diffstat (limited to '')
-rw-r--r--util.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/util.c b/util.c
deleted file mode 100644
index d39d73c..0000000
--- a/util.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* See LICENSE file for copyright and license details. */
2#include "dwm.h"
3#include <stdarg.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <sys/wait.h>
7#include <unistd.h>
8
9/* extern */
10
11void *
12emallocz(unsigned int size) {
13 void *res = calloc(1, size);
14
15 if(!res)
16 eprint("fatal: could not malloc() %u bytes\n", size);
17 return res;
18}
19
20void
21eprint(const char *errstr, ...) {
22 va_list ap;
23
24 va_start(ap, errstr);
25 vfprintf(stderr, errstr, ap);
26 va_end(ap);
27 exit(EXIT_FAILURE);
28}
29
30void
31spawn(const char *arg) {
32 static char *shell = NULL;
33
34 if(!shell && !(shell = getenv("SHELL")))
35 shell = "/bin/sh";
36 if(!arg)
37 return;
38 /* The double-fork construct avoids zombie processes and keeps the code
39 * clean from stupid signal handlers. */
40 if(fork() == 0) {
41 if(fork() == 0) {
42 if(dpy)
43 close(ConnectionNumber(dpy));
44 setsid();
45 execl(shell, shell, "-c", arg, (char *)NULL);
46 fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg);
47 perror(" failed");
48 }
49 exit(0);
50 }
51 wait(0);
52}