aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/texec.c
blob: 87c3f77bf824a479f0dfe965a2fe7c55c3f673cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <lib9.h>
#include <thread.h>
extern int _threaddebuglevel;

void
doexec(void *v)
{
	char **argv = v;

print("doexec\n");
	procexec(nil, argv[0], argv);
	sendp(threadwaitchan(), nil);
}

void
threadmain(int argc, char **argv)
{
	Channel *c;
	Waitmsg *w;

	ARGBEGIN{
	case 'D':
		_threaddebuglevel = ~0;
		break;
	}ARGEND

	c = threadwaitchan();
	proccreate(doexec, argv, 8192);
	w = recvp(c);
	if(w == nil)
		print("exec failed: %r\n");
	else
		print("%d %lud %lud %lud %s\n", w->pid, w->time[0], w->time[1], w->time[2], w->msg);
	threadexits(nil);
}