diff options
author | rsc <devnull@localhost> | 2004-10-22 17:15:47 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-10-22 17:15:47 +0000 |
commit | 793d93626b7d01ff47e1c0b483e25ccf894ccb51 (patch) | |
tree | 937f4f55cf10b2ba1518ee77f97f17695fca9e15 /src/libthread | |
parent | ba15d71b0cf27ba89d14b547d7ded643e5de6a01 (diff) | |
download | plan9port-793d93626b7d01ff47e1c0b483e25ccf894ccb51.tar.gz plan9port-793d93626b7d01ff47e1c0b483e25ccf894ccb51.tar.bz2 plan9port-793d93626b7d01ff47e1c0b483e25ccf894ccb51.zip |
new test program
Diffstat (limited to 'src/libthread')
-rw-r--r-- | src/libthread/tspawn.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libthread/tspawn.c b/src/libthread/tspawn.c new file mode 100644 index 00000000..97962c5d --- /dev/null +++ b/src/libthread/tspawn.c @@ -0,0 +1,41 @@ +#include <lib9.h> +#include <thread.h> +extern int _threaddebuglevel; + +void +doexec(void *v) +{ + int fd[3]; + char **argv = v; + + print("exec failed: %r\n"); + sendp(threadwaitchan(), nil); + threadexits(nil); +} + +void +threadmain(int argc, char **argv) +{ + int fd[3]; + Channel *c; + Waitmsg *w; + + ARGBEGIN{ + case 'D': + _threaddebuglevel = ~0; + break; + }ARGEND + + c = threadwaitchan(); + fd[0] = dup(0, -1); + fd[1] = dup(1, -1); + fd[2] = dup(2, -1); + if(threadspawn(fd, argv[0], argv) < 0) + sysfatal("threadspawn: %r"); + w = recvp(c); + if(w == nil) + print("exec/recvp 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); +} |