X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=util.c;h=d39d73c65b26873d3d2e59f4eb1633b17a13c7f6;hp=990ad28c0cc28c728e219347dc5a227d170ad3ce;hb=2091200c957783deed032380d56c4199a23c6b81;hpb=9955ddc978c2e6acfe246f29f1d317b55d860757 diff --git a/util.c b/util.c index 990ad28..d39d73c 100644 --- a/util.c +++ b/util.c @@ -1,7 +1,4 @@ -/* - * (C)opyright MMVI Anselm R. Garbe - * See LICENSE file for license details. - */ +/* See LICENSE file for copyright and license details. */ #include "dwm.h" #include #include @@ -9,29 +6,19 @@ #include #include -/* static */ - -static void -bad_malloc(unsigned int size) -{ - eprint("fatal: could not malloc() %u bytes\n", size); -} - /* extern */ void * -emallocz(unsigned int size) -{ +emallocz(unsigned int size) { void *res = calloc(1, size); if(!res) - bad_malloc(size); + eprint("fatal: could not malloc() %u bytes\n", size); return res; } void -eprint(const char *errstr, ...) -{ +eprint(const char *errstr, ...) { va_list ap; va_start(ap, errstr); @@ -41,22 +28,22 @@ eprint(const char *errstr, ...) } void -spawn(Arg *arg) -{ +spawn(const char *arg) { static char *shell = NULL; if(!shell && !(shell = getenv("SHELL"))) shell = "/bin/sh"; - - if(!arg->cmd) + if(!arg) return; + /* The double-fork construct avoids zombie processes and keeps the code + * clean from stupid signal handlers. */ if(fork() == 0) { if(fork() == 0) { if(dpy) close(ConnectionNumber(dpy)); setsid(); - execl(shell, shell, "-c", arg->cmd, NULL); - fprintf(stderr, "dwm: execl '%s'", arg->cmd); + execl(shell, shell, "-c", arg, (char *)NULL); + fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg); perror(" failed"); } exit(0);