aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/samterm
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-02-29 22:10:26 +0000
committerrsc <devnull@localhost>2004-02-29 22:10:26 +0000
commit5a8e63b2f016735364d17866d5e2bcb35d20c78b (patch)
treed5d0ce11e087efaf81c77311bac9d30aed41783d /src/cmd/samterm
parentd51419bf4397cf13d0c50bf84c125477c6bed307 (diff)
downloadplan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.tar.gz
plan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.tar.bz2
plan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.zip
Fighting the good fight.
Move libfmt, libutf into subdirectories of lib9. Add poll-based socket i/o to libthread, so that we can avoid using multiple procs when possible, thus removing dependence on crappy pthreads implementations. Convert samterm, acme to the single-proc libthread. Bring libcomplete, acme up-to-date w.r.t. Plan 9 distribution.
Diffstat (limited to 'src/cmd/samterm')
-rw-r--r--src/cmd/samterm/plan9.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
index f49393e6..60ef5c0e 100644
--- a/src/cmd/samterm/plan9.c
+++ b/src/cmd/samterm/plan9.c
@@ -99,10 +99,11 @@ extproc(void *argv)
c = arg[0];
fd = (int)arg[1];
+ threadfdnoblock(fd);
i = 0;
for(;;){
i = 1-i; /* toggle */
- n = read(fd, plumbbuf[i].data, sizeof plumbbuf[i].data);
+ n = threadread(fd, plumbbuf[i].data, sizeof plumbbuf[i].data);
if(n <= 0){
fprint(2, "samterm: extern read error: %r\n");
threadexits("extern"); /* not a fatal error */
@@ -165,7 +166,7 @@ extstart(void)
plumbc = chancreate(sizeof(int), 0);
arg[0] = plumbc;
arg[1] = (void*)fd;
- proccreate(extproc, arg, STACK);
+ threadcreate(extproc, arg, STACK);
atexit(removeextern);
}
@@ -226,9 +227,10 @@ plumbproc(void *argv)
fdp = arg[1];
i = 0;
+ threadfdnoblock(*fdp);
for(;;){
i = 1-i; /* toggle */
- n = read(*fdp, plumbbuf[i].data, READBUFSIZE);
+ n = threadread(*fdp, plumbbuf[i].data, READBUFSIZE);
if(n <= 0){
fprint(2, "samterm: plumb read error: %r\n");
threadexits("plumb"); /* not a fatal error */
@@ -258,7 +260,7 @@ plumbstart(void)
}
arg[0] =plumbc;
arg[1] = &fd;
- proccreate(plumbproc, arg, STACK);
+ threadcreate(plumbproc, arg, STACK);
return 1;
}
#endif
@@ -278,9 +280,10 @@ hostproc(void *arg)
c = arg;
i = 0;
+ threadfdnoblock(hostfd[0]);
for(;;){
i = 1-i; /* toggle */
- n = read(hostfd[0], hostbuf[i].data, sizeof hostbuf[i].data);
+ n = threadread(hostfd[0], hostbuf[i].data, sizeof hostbuf[i].data);
if(n <= 0){
fprint(2, "samterm: host read error: %r\n");
threadexitsall("host");
@@ -295,5 +298,5 @@ void
hoststart(void)
{
hostc = chancreate(sizeof(int), 0);
- proccreate(hostproc, hostc, STACK);
+ threadcreate(hostproc, hostc, STACK);
}