util.c
changeset 532 651f2c868b31
parent 471 740c4bfc3124
child 643 e90bf387bf6f
equal deleted inserted replaced
531:96563762b4ad 532:651f2c868b31
     1 /*
     1 /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
     2  * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
       
     3  * See LICENSE file for license details.
     2  * See LICENSE file for license details.
     4  */
     3  */
     5 #include "dwm.h"
     4 #include "dwm.h"
     6 #include <stdarg.h>
     5 #include <stdarg.h>
     7 #include <stdio.h>
     6 #include <stdio.h>
    31 }
    30 }
    32 
    31 
    33 void *
    32 void *
    34 erealloc(void *ptr, unsigned int size) {
    33 erealloc(void *ptr, unsigned int size) {
    35 	void *res = realloc(ptr, size);
    34 	void *res = realloc(ptr, size);
       
    35 
    36 	if(!res)
    36 	if(!res)
    37 		eprint("fatal: could not malloc() %u bytes\n", size);
    37 		eprint("fatal: could not malloc() %u bytes\n", size);
    38 	return res;
    38 	return res;
    39 }
    39 }
    40 
    40 
    42 spawn(Arg *arg) {
    42 spawn(Arg *arg) {
    43 	static char *shell = NULL;
    43 	static char *shell = NULL;
    44 
    44 
    45 	if(!shell && !(shell = getenv("SHELL")))
    45 	if(!shell && !(shell = getenv("SHELL")))
    46 		shell = "/bin/sh";
    46 		shell = "/bin/sh";
    47 
       
    48 	if(!arg->cmd)
    47 	if(!arg->cmd)
    49 		return;
    48 		return;
    50 	/* The double-fork construct avoids zombie processes and keeps the code
    49 	/* The double-fork construct avoids zombie processes and keeps the code
    51 	 * clean from stupid signal handlers. */
    50 	 * clean from stupid signal handlers. */
    52 	if(fork() == 0) {
    51 	if(fork() == 0) {