summary refs log tree commit diff stats
path: root/doc/manual/exceptions.txt
Commit message (Collapse)AuthorAgeFilesLines
* documentation build cleaned upAndreas Rumpf2016-05-311-1/+1
|
* documentation proper bracketingAndreas Rumpf2016-01-271-1/+1
|
* Promote "echo" syntax without parenthesisAdam Stankiewicz2016-01-261-5/+5
|
* Clarify documentation about "except clauses"def2015-01-171-1/+1
| | | | | They're called type conversions. Type casts are done with cast[T](...) and are not type safe.
* New section "Except clauses" in the manualMaurizio Tomasi2015-01-141-0/+35
| | | | | | This new section explains how to use `getCurrentException` and `getCurrentExceptionMsg`. See the thread http://forum.nim-lang.org/t/752 .
* fixes #1742Araq2014-12-241-0/+21
|
* documented 'defer' statementAraq2014-12-241-23/+18
|
* onRaise doesn't work as documented as is dubiousAraq2014-11-141-28/+0
|
* fixes #930Araq2014-11-141-2/+5
|
* manual split up into multiple files; documented the new concurrency systemAraq2014-10-021-0/+132
8 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/* (C)opyright MMVI-MMVII 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>

/* extern */

void *
emallocz(unsigned int size) {
	void *res = calloc(1, size);

	if(!res)
		eprint("fatal: could not malloc() %u bytes\n", 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) {
	static char *shell = NULL;

	if(!shell && !(shell = getenv("SHELL")))
		shell = "/bin/sh";
	if(!arg->cmd)
		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, (char *)NULL);
			fprintf(stderr, "dwm: execl '%s -c %s'", shell, arg->cmd);
			perror(" failed");
		}
		exit(0);
	}
	wait(0);
}