diff options
author | rsc <devnull@localhost> | 2004-12-25 21:56:33 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-12-25 21:56:33 +0000 |
commit | 1544f90960275dc9211bde30329c3258e0e1bf38 (patch) | |
tree | f55e7a73c03aaa24daa7cc2ad02822b921c477f9 /src/libthread/test/tspawnloop.c | |
parent | 7788fd54094693384ef5c92c475656dba8819feb (diff) | |
download | plan9port-1544f90960275dc9211bde30329c3258e0e1bf38.tar.gz plan9port-1544f90960275dc9211bde30329c3258e0e1bf38.tar.bz2 plan9port-1544f90960275dc9211bde30329c3258e0e1bf38.zip |
New thread library
Diffstat (limited to 'src/libthread/test/tspawnloop.c')
-rw-r--r-- | src/libthread/test/tspawnloop.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libthread/test/tspawnloop.c b/src/libthread/test/tspawnloop.c new file mode 100644 index 00000000..8835267f --- /dev/null +++ b/src/libthread/test/tspawnloop.c @@ -0,0 +1,41 @@ +#include "u.h" +#include "libc.h" +#include "thread.h" + +void +execproc(void *v) +{ + int i, fd[3]; + char buf[100], *args[3]; + + i = (int)v; + sprint(buf, "%d", i); + fd[0] = dup(0, -1); + fd[1] = dup(1, -1); + fd[2] = dup(2, -1); + args[0] = "echo"; + args[1] = buf; + args[2] = nil; + threadexec(nil, fd, args[0], args); +} + +void +threadmain(int argc, char **argv) +{ + int i; + Channel *c; + Waitmsg *w; + + ARGBEGIN{ + case 'D': + break; + }ARGEND + + c = threadwaitchan(); + for(i=0;; i++){ + proccreate(execproc, (void*)i, 16384); + w = recvp(c); + if(w == nil) + sysfatal("exec/recvp failed: %r"); + } +} |