Index: src/tests/concurrent/coroutineYield.c
===================================================================
--- src/tests/concurrent/coroutineYield.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/concurrent/coroutineYield.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -4,4 +4,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -13,5 +15,5 @@
 }
 
-#ifdef LONG_TEST
+#ifdef TEST_LONG
 static const unsigned long N = 600_000ul;
 #else
@@ -33,9 +35,10 @@
 int main(int argc, char* argv[]) {
 	Coroutine c;
-	for(int i = 0; i < N; i++) {
+	for(int i = 0; TEST(i < N); i++) {
 		sout | "Thread 1" | endl;
 		resume(c);
 		sout | "Thread 2" | endl;
 		yield();
+		KICK_WATCHDOG;
 	}
 }
Index: src/tests/concurrent/preempt.c
===================================================================
--- src/tests/concurrent/preempt.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/concurrent/preempt.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -2,4 +2,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -11,5 +13,5 @@
 }
 
-#ifdef LONG_TEST
+#ifdef TEST_LONG
 static const unsigned long N = 30_000ul;
 #else
@@ -30,5 +32,5 @@
 
 void main(worker_t & this) {
-	while(counter < N) {
+	while(TEST(counter < N)) {
 		__cfaabi_check_preemption();
 		if( (counter % 7) == this.value ) {
@@ -40,4 +42,5 @@
 		}
 		__cfaabi_check_preemption();
+		KICK_WATCHDOG;
 	}
 }
Index: src/tests/concurrent/signal/block.c
===================================================================
--- src/tests/concurrent/signal/block.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/concurrent/signal/block.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -14,4 +14,6 @@
 #include <time>
 
+#include "long_tests.h"
+
 #ifndef PREEMPTION_RATE
 #define PREEMPTION_RATE 10`ms
@@ -22,5 +24,5 @@
 }
 
-#ifdef LONG_TEST
+#ifdef TEST_LONG
 static const unsigned long N = 150_000ul;
 #else
@@ -66,6 +68,7 @@
 thread Waiter {};
 void main( Waiter & this ) {
-	for( int i = 0; i < N; i++ ) {
+	for( int i = 0; TEST(i < N); i++ ) {
 		wait_op( globalA, globalB, i );
+		KICK_WATCHDOG;
 	}
 }
Index: src/tests/concurrent/signal/disjoint.c
===================================================================
--- src/tests/concurrent/signal/disjoint.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/concurrent/signal/disjoint.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -4,4 +4,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -13,5 +15,5 @@
 }
 
-#ifdef LONG_TEST
+#ifdef TEST_LONG
 static const unsigned long N = 300_000ul;
 #else
@@ -71,5 +73,5 @@
 	if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
 
-	return d.counter < N;
+	return TEST(d.counter < N);
 }
 
@@ -77,5 +79,5 @@
 
 void main( Waiter & this ) {
-	while( wait( mut, data ) ) { yield(); }
+	while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); }
 }
 
@@ -94,5 +96,5 @@
 
 	//This is technically a mutual exclusion violation but the mutex monitor protects us
-	bool running = data.counter < N && data.counter > 0;
+	bool running = TEST(data.counter < N) && data.counter > 0;
 	if( data.state != SIGNAL && running ) {
 		sout | "ERROR Eager signal" | data.state | endl;
Index: src/tests/concurrent/signal/wait.c
===================================================================
--- src/tests/concurrent/signal/wait.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/concurrent/signal/wait.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -12,4 +12,6 @@
 #include <time>
 
+#include "long_tests.h"
+
 #ifndef PREEMPTION_RATE
 #define PREEMPTION_RATE 10`ms
@@ -20,5 +22,5 @@
 }
 
-#ifdef LONG_TEST
+#ifdef TEST_LONG
 static const unsigned long N = 375_000ul;
 #else
@@ -90,6 +92,7 @@
 // Waiter ABC
 void main( WaiterABC & this ) {
-	for( int i = 0; i < N; i++ ) {
+	for( int i = 0; TEST(i < N); i++ ) {
 		wait( condABC, globalA, globalB, globalC );
+		KICK_WATCHDOG;
 	}
 
@@ -100,6 +103,7 @@
 // Waiter AB
 void main( WaiterAB & this ) {
-	for( int i = 0; i < N; i++ ) {
+	for( int i = 0; TEST(i < N); i++ ) {
 		wait( condAB , globalA, globalB );
+		KICK_WATCHDOG;
 	}
 
@@ -110,6 +114,7 @@
 // Waiter AC
 void main( WaiterAC & this ) {
-	for( int i = 0; i < N; i++ ) {
+	for( int i = 0; TEST(i < N); i++ ) {
 		wait( condAC , globalA, globalC );
+		KICK_WATCHDOG;
 	}
 
@@ -120,6 +125,7 @@
 // Waiter BC
 void main( WaiterBC & this ) {
-	for( int i = 0; i < N; i++ ) {
+	for( int i = 0; TEST(i < N); i++ ) {
 		wait( condBC , globalB, globalC );
+		KICK_WATCHDOG;
 	}
 
Index: src/tests/long_tests.h
===================================================================
--- src/tests/long_tests.h	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
+++ src/tests/long_tests.h	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <unistd.h>
+
+#if   defined(TEST_FOREVER)
+#define TEST(x) 1
+#define KICK_WATCHDOG write(STDOUT_FILENO, ".", 1)
+#elif defined(TEST_LONG)
+#define TEST(x) x
+#define KICK_WATCHDOG
+#else
+#define TEST(x) x
+#define KICK_WATCHDOG
+#endif
Index: src/tests/preempt_longrun/Makefile.am
===================================================================
--- src/tests/preempt_longrun/Makefile.am	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/Makefile.am	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -19,9 +19,11 @@
 preempt=10ul\`ms
 debug=-debug
+type=LONG
 
 REPEAT = ${abs_top_srcdir}/tools/repeat
+WATCHDOG = ${abs_top_srcdir}/tools/watchdog
 TIME = /usr/bin/time -f "%E"
 
-BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -DLONG_TEST
+BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell echo $(type) | tr a-z A-Z)
 CFLAGS = ${BUILD_FLAGS}
 CC = @CFA_BINDIR@/@CFA_NAME@
@@ -29,7 +31,16 @@
 TESTS = block coroutine create disjoint enter enter3 processor stack wait yield
 
-.INTERMEDIATE: ${TESTS}
+# .INTERMEDIATE: ${TESTS}
 
 all-local: ${TESTS:=.run}
+
+runall : ${TESTS:=.run}
+	@ echo "All programs terminated normally"
+
+watchall : ${TESTS:=.watch}
+	@ echo "All programs terminated normally"
+
+compileall : ${TESTS}
+	@ echo "Compiled"
 
 clean-local:
@@ -44,4 +55,9 @@
 	@ echo -e "${<}: SUCCESS\n"
 
+%.watch : % ${WATCHDOG}
+	@ time ${WATCHDOG} ./${<}
+	@ rm ${<}
+	@ echo -e "${<}: SUCCESS\n"
+
 %.time : % ${REPEAT}
 	@ ${REPEAT} -i -s -- $(repeats) $(TIME) -a -o times.log ./${<}
@@ -49,4 +65,7 @@
 	@ echo -e "${<}: SUCCESS\n"
 
-${REPEAT}:
+${REPEAT}: ${abs_top_srcdir}/tools/Makefile
 	@+make -C ${abs_top_srcdir}/tools/
+
+${WATCHDOG}: ${abs_top_srcdir}/tools/Makefile
+	@+make -C ${abs_top_srcdir}/tools/
Index: src/tests/preempt_longrun/Makefile.in
===================================================================
--- src/tests/preempt_longrun/Makefile.in	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/Makefile.in	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -452,7 +452,9 @@
 preempt = 10ul\`ms
 debug = -debug
+type = LONG
 REPEAT = ${abs_top_srcdir}/tools/repeat
+WATCHDOG = ${abs_top_srcdir}/tools/watchdog
 TIME = /usr/bin/time -f "%E"
-BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -DLONG_TEST
+BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ -O2 -DPREEMPTION_RATE=${preempt} -I.. -I. -DTEST_$(shell echo $(type) | tr a-z A-Z)
 TESTS = block coroutine create disjoint enter enter3 processor stack wait yield
 all: all-am
@@ -873,7 +875,16 @@
 
 
-.INTERMEDIATE: ${TESTS}
+# .INTERMEDIATE: ${TESTS}
 
 all-local: ${TESTS:=.run}
+
+runall : ${TESTS:=.run}
+	@ echo "All programs terminated normally"
+
+watchall : ${TESTS:=.watch}
+	@ echo "All programs terminated normally"
+
+compileall : ${TESTS}
+	@ echo "Compiled"
 
 clean-local:
@@ -888,4 +899,9 @@
 	@ echo -e "${<}: SUCCESS\n"
 
+%.watch : % ${WATCHDOG}
+	@ time ${WATCHDOG} ./${<}
+	@ rm ${<}
+	@ echo -e "${<}: SUCCESS\n"
+
 %.time : % ${REPEAT}
 	@ ${REPEAT} -i -s -- $(repeats) $(TIME) -a -o times.log ./${<}
@@ -893,5 +909,8 @@
 	@ echo -e "${<}: SUCCESS\n"
 
-${REPEAT}:
+${REPEAT}: ${abs_top_srcdir}/tools/Makefile
+	@+make -C ${abs_top_srcdir}/tools/
+
+${WATCHDOG}: ${abs_top_srcdir}/tools/Makefile
 	@+make -C ${abs_top_srcdir}/tools/
 
Index: src/tests/preempt_longrun/create.c
===================================================================
--- src/tests/preempt_longrun/create.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/create.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -2,4 +2,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -19,6 +21,7 @@
 int main(int argc, char* argv[]) {
 	processor p;
-	for(int i = 0; i < N; i++) {
+	for(int i = 0; TEST(i < N); i++) {
 		worker_t w[7];
+		KICK_WATCHDOG;
 	}
 }
Index: src/tests/preempt_longrun/enter.c
===================================================================
--- src/tests/preempt_longrun/enter.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/enter.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -3,4 +3,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -15,10 +17,12 @@
 
 monitor mon_t {};
-void foo( mon_t & mutex this ) {}
+void foo( mon_t & mutex this ) {
+	KICK_WATCHDOG;
+}
 
 mon_t mon;
 thread worker_t {};
 void main( worker_t & this ) {
-	for( unsigned long i = 0; i < N; i++ ) {
+	for( unsigned long i = 0; TEST(i < N); i++ ) {
 		foo( mon );
 	}
Index: src/tests/preempt_longrun/enter3.c
===================================================================
--- src/tests/preempt_longrun/enter3.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/enter3.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -3,4 +3,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -18,10 +20,12 @@
 mon_t mon1, mon2, mon3;
 
-void foo( mon_t & mutex a, mon_t & mutex b, mon_t & mutex c ) {}
+void foo( mon_t & mutex a, mon_t & mutex b, mon_t & mutex c ) {
+	KICK_WATCHDOG;
+}
 
 thread worker_t {};
 
 void main( worker_t & this ) {
-	for( unsigned long i = 0; i < N; i++ ) {
+	for( unsigned long i = 0; TEST(i < N); i++ ) {
 		foo( mon1, mon2, mon3 );
 	}
Index: src/tests/preempt_longrun/processor.c
===================================================================
--- src/tests/preempt_longrun/processor.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/processor.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -4,4 +4,6 @@
 
 #include <unistd.h>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -17,18 +19,15 @@
 int main(int argc, char* argv[]) {
 	processor * p[15];
-	write(STDOUT_FILENO, "Preparing\n", sizeof("Preparing\n"));
 	for ( int pi = 0; pi < 15; pi++ ) {
 		p[pi] = new();
 	}
-	write(STDOUT_FILENO, "Starting\n", sizeof("Starting\n"));
-	for ( int i = 0; i < N; i++) {
+	for ( int i = 0; TEST(i < N); i++) {
 		int pi = i % 15;
 		delete( p[pi] );
 		p[pi] = new();
+		KICK_WATCHDOG;
 	}
-	write(STDOUT_FILENO, "Stopping\n", sizeof("Stopping\n"));
 	for ( int pi = 0; pi < 15; pi++ ) {
 		delete( p[pi] );
 	}
-	write(STDOUT_FILENO, "Done\n", sizeof("Done\n"));
 }
Index: src/tests/preempt_longrun/stack.c
===================================================================
--- src/tests/preempt_longrun/stack.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/stack.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -3,4 +3,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -18,10 +20,11 @@
 	volatile long long a = 326_417ul;
 	volatile long long n = 1l;
-	for (volatile long long i = 0; i < p; i++) {
+	for (volatile long long i = 0; TEST(i < p); i++) {
 		n *= a;
 		n %= p;
+		KICK_WATCHDOG;
 	}
 
-	if( n != a ) {
+	if( !TEST(n == a) ) {
 		abort();
 	}
Index: src/tests/preempt_longrun/yield.c
===================================================================
--- src/tests/preempt_longrun/yield.c	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ src/tests/preempt_longrun/yield.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -2,4 +2,6 @@
 #include <thread>
 #include <time>
+
+#include "long_tests.h"
 
 #ifndef PREEMPTION_RATE
@@ -11,5 +13,5 @@
 }
 
-#ifdef LONG_TEST
+#ifdef TEST_LONG
 static const unsigned long N = 9_750_000ul;
 #else
@@ -20,6 +22,7 @@
 
 void main(worker_t & this) {
-	for(int i = 0; i < N; i++) {
+	for(int i = 0; TEST(i < N); i++) {
 		yield();
+		KICK_WATCHDOG;
 	}
 }
Index: tools/Makefile.am
===================================================================
--- tools/Makefile.am	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ tools/Makefile.am	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -18,5 +18,5 @@
 CFLAGS = -Wall -Wextra -O2 -g
 
-noinst_PROGRAMS = busy catchsig repeat
+noinst_PROGRAMS = busy catchsig repeat watchdog
 
 busy_SOURCES     = busy.c
@@ -24,2 +24,3 @@
 catchsig_SOURCES = catchsig.c
 repeat_SOURCES   = repeat.c
+watchdog_SOURCES = watchdog.c
Index: tools/Makefile.in
===================================================================
--- tools/Makefile.in	(revision 85b1deb20af020daa008d82abbbc54f9b152d5c0)
+++ tools/Makefile.in	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -92,5 +92,6 @@
 build_triplet = @build@
 host_triplet = @host@
-noinst_PROGRAMS = busy$(EXEEXT) catchsig$(EXEEXT) repeat$(EXEEXT)
+noinst_PROGRAMS = busy$(EXEEXT) catchsig$(EXEEXT) repeat$(EXEEXT) \
+	watchdog$(EXEEXT)
 subdir = tools
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -115,4 +116,7 @@
 repeat_OBJECTS = $(am_repeat_OBJECTS)
 repeat_LDADD = $(LDADD)
+am_watchdog_OBJECTS = watchdog.$(OBJEXT)
+watchdog_OBJECTS = $(am_watchdog_OBJECTS)
+watchdog_LDADD = $(LDADD)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -143,6 +147,8 @@
 am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
-SOURCES = $(busy_SOURCES) $(catchsig_SOURCES) $(repeat_SOURCES)
-DIST_SOURCES = $(busy_SOURCES) $(catchsig_SOURCES) $(repeat_SOURCES)
+SOURCES = $(busy_SOURCES) $(catchsig_SOURCES) $(repeat_SOURCES) \
+	$(watchdog_SOURCES)
+DIST_SOURCES = $(busy_SOURCES) $(catchsig_SOURCES) $(repeat_SOURCES) \
+	$(watchdog_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -295,4 +301,5 @@
 catchsig_SOURCES = catchsig.c
 repeat_SOURCES = repeat.c
+watchdog_SOURCES = watchdog.c
 all: all-am
 
@@ -344,4 +351,8 @@
 	$(AM_V_CCLD)$(LINK) $(repeat_OBJECTS) $(repeat_LDADD) $(LIBS)
 
+watchdog$(EXEEXT): $(watchdog_OBJECTS) $(watchdog_DEPENDENCIES) $(EXTRA_watchdog_DEPENDENCIES) 
+	@rm -f watchdog$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(watchdog_OBJECTS) $(watchdog_LDADD) $(LIBS)
+
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -353,4 +364,5 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/catchsig.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/repeat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/watchdog.Po@am__quote@
 
 .c.o:
Index: tools/error.c
===================================================================
--- tools/error.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
+++ tools/error.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -0,0 +1,10 @@
+#include <signal.h>
+#include <unistd.h>
+
+int main() {
+	// while(1);
+	sleep(2);
+	// raise(SIGABRT);
+	raise(SIGSEGV);
+	return 0;
+}
Index: tools/watchdog.c
===================================================================
--- tools/watchdog.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
+++ tools/watchdog.c	(revision 7bdcac1f3631ee6408a86b4d0321433114fee6d3)
@@ -0,0 +1,175 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+char * this_cmd = NULL;
+
+void parse_args(int argc, char * argv[]);
+int run();
+void printcmd();
+
+int main(int argc, char * argv[]) {
+	parse_args(argc, argv);
+
+	int retcode = run();
+	if( !WIFEXITED(retcode) ) {
+		printf("Child Error : %d ", retcode); printcmd();
+		return retcode;
+	}
+
+	printf("Child exited normally "); printcmd();
+	return 0;
+}
+
+void usage( FILE * out, int code ) {
+	fprintf(out, "%s [OPTION] [--] N CMD\n", this_cmd);
+	fprintf(out, "Run command, killing it if it doesn't print for more than 5 continuous seconds\n\n");
+	fprintf(out, "\t-h,--help\tprint this usage message\n");
+	exit(code);
+}
+
+char ** cmd_to_run = NULL;
+pid_t child_pid = 0;
+int pipe_fds[2];
+
+void arg_error(void) {
+	fprintf(stderr,"\n");
+	usage(stderr, 1);
+}
+
+void parse_args(int argc, char * argv[]) {
+	this_cmd = argv[0];
+
+	enum { Help, };
+	static struct option long_opts[] = {
+		{ "help", no_argument, 0, Help },
+		{ 0, 0, 0, 0 }
+	}; // long_opts
+	int long_index;
+
+	int c;
+	while ( (c = getopt_long( argc, argv, "h", long_opts, &long_index)) != -1 ) {
+		switch ( c ) {
+			case Help:
+			case 'h':
+				usage(stdout, 0);
+				break;
+			default:
+				arg_error();
+				break;
+		} // switch
+	} // while
+
+	if( argc < optind + 1 ) {
+		fprintf(stderr, "Too few arguments\n");
+		arg_error();
+	}
+
+	cmd_to_run = argv + optind;
+}
+
+static void exit_handler (__attribute__((unused)) int a, __attribute__((unused)) void * b) {
+	close(pipe_fds[0]);
+	if(child_pid != 0) kill(child_pid, SIGKILL);
+}
+
+#define checked(call, ...) ({int ret = call(__VA_ARGS__); if (ret == -1) { perror(#call); exit(1); } ret;})
+
+void run_child();
+void make_noblock(int fd);
+void sink(int fd);
+int waitfd(int fd);
+
+int run() {
+	on_exit(exit_handler, NULL);
+	checked(pipe, pipe_fds);
+
+	printf("Watching command: "); printcmd();
+
+	child_pid = checked(fork);
+	if (child_pid == 0) { run_child(); }
+
+	close(pipe_fds[1]);
+	make_noblock(pipe_fds[0]);
+
+	int status;
+	while(waitpid(child_pid, &status, WNOHANG) == 0) {
+		if(waitfd(pipe_fds[0]) == 0) {
+			printf("Child Deadlocked "); printcmd();
+			exit(127);
+		}
+		sink(pipe_fds[0]);
+	}
+
+	child_pid = 0;
+	return status;
+
+	return 0;
+}
+
+void make_noblock(int fd) {
+	int flags = fcntl(fd, F_GETFL);
+	flags |= O_NONBLOCK;
+	fcntl(fd, F_SETFL, flags );
+}
+
+void sink(int fd) {
+	char buff[100];
+	int len = 100;
+	int rv;
+	do {
+		rv = read( fd, buff, len );
+	}
+	while(rv > 0);
+}
+
+int waitfd(int fd) {
+	fd_set set;
+	FD_ZERO(&set);
+	FD_SET(fd, &set);
+
+	struct timeval timeout;
+	timeout.tv_sec = 5;
+	timeout.tv_usec = 0;
+
+	int rv = select(fd + 1, &set, NULL, NULL, &timeout);
+	if(rv == -1) {
+		perror("select\n");
+		exit(1);
+	}
+	return rv;
+}
+
+void run_child() {
+	/* This is the child process. */
+	while ((dup2(pipe_fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
+
+	close(pipe_fds[1]);
+	close(pipe_fds[0]);
+
+	execvp ( *cmd_to_run, cmd_to_run);
+
+	/* The execvp  function returns only if an error occurs.  */
+	fprintf(stderr, "an error occurred in execvp\n");
+	abort ();
+}
+
+void printcmd() {
+	if(!cmd_to_run) return;
+	char ** cmd = cmd_to_run;
+	while (*cmd) {
+		printf("%s ", *cmd);
+		cmd++;
+	}
+	printf("\n");
+}
