about summary refs log tree commit diff stats
/*
 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
 * See LICENSE file for license details.
 */
#include "dwm.h"

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>

/* static */

static void
bad_malloc(unsigned int size)
{
	fprintf(stderr, "fatal: could not malloc() %d bytes\n",
			(int) size);
	exit(EXIT_FAILURE);
}

/* extern */

void *
emallocz(unsigned int size)
{
	void *res = calloc(1, size);
	if(!res)
		bad_malloc(size);
	return res;
}

void
eprint(const char *errstr, ...) {
	va_list ap;
	va_start(ap, errstr);
	vfprintf(stderr, errstr, ap);
	va_end(ap);
	exit(EXIT_FAILURE);
}

void
spawn(Arg *arg)
{
	char **argv = (char **)arg->argv;
	if(!argv || !argv[0])
		return;
	if(fork() == 0) {
		if(fork() == 0) {
			if(dpy)
				close(ConnectionNumber(dpy));
			setsid();
			execvp(argv[0], argv);
			fprintf(stderr, "dwm: execvp %s", argv[0]);
			perror(" failed");
		}
		exit(EXIT_FAILURE);
	}
	wait(0);
}
Commit message (Collapse)AuthorAgeFilesLines
* lt will point to a foo-layout during cleanup now (Gottox' suggestion), and ↵Anselm R Garbe2008-06-111-1/+6
| | | | togglelayout respects Arg->v
* integrated Peter Hartlich's patch, removed const char *c from union, ↵Anselm R Garbe2008-06-112-26/+9
| | | | simplified togglelayout
* applied anydot's patchset.diffAnselm R Garbe2008-06-113-211/+206
|
* final version -- Gottox verified it using the test driverarg@suckless.org
17ab859bbda584'>replaced isvisible with a macroAnselm R Garbe2008-05-221-17/+12 | * removed emalloczAnselm R Garbe2008-05-221-11/+2 | * s/int/uint/ in config.hAnselm R Garbe2008-05-221-38/+38 | * removed debug output, sanitized tag limit checkAnselm R Garbe2008-05-221-11/+2 | * setmfact argument was wrongAnselm R Garbe2008-05-221-2/+2 | * Key.mod is uint, Client.[old]bw is intAnselm R Garbe2008-05-221-2/+2 | * s/unsigned long/ulong/Anselm R Garbe2008-05-221-10/+11 | * s/nextunfloating/nexttiled/, changed zoom() behaviorAnselm R Garbe2008-05-221-12/+12 | * s/unsigned int/uint/Anselm R Garbe2008-05-221-33/+34 | * s/void */const void */Anselm R Garbe2008-05-221-32/+32 | * applied Gottox bitmask + void *arg patchAnselm R Garbe2008-05-223-168/+138 | * some minor fixesanselm@anselm12008-05-191-2/+2 | * simplificationanselm@anselm12008-05-192-5/+3 | * reverted dist target in Makefileanselm@anselm12008-05-191-1/+1 | * merged tile.c again into dwm.canselm@anselm12008-05-193-106/+101 | * take bar into accountAnselm R Garbe2008-05-191-1/+1 | * be more polite to clients which like to appear outside the window area, but ↵Anselm R Garbe2008-05-191-6/+6 | | | | still on the screen * fixed commentAnselm R Garbe2008-05-191-1/+1 | * fixAnselm R Garbe2008-05-191-1/+1 | * make it easier for the user, if Xinerama support is given, always use the ↵Anselm R Garbe2008-05-193-16/+37 | | | | screen 0 as window area/bar area, everything else can be used for floating clients * improving space usage if master is left of stack (default)Anselm R Garbe2008-05-191-3/+5 | * only snap within window areaAnselm R Garbe2008-05-191-12/+19 |