aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9term/win.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-26 21:37:31 +0000
committerrsc <devnull@localhost>2004-12-26 21:37:31 +0000
commit60535a5ff621d2e0f1eb91a08c0e624cc6c76fbd (patch)
treec3bdc4a7c60d477c3bbbdf07b8e4896d27440086 /src/cmd/9term/win.c
parentf99790979b4a659d7f6e490fbb8b26d630804eed (diff)
downloadplan9port-60535a5ff621d2e0f1eb91a08c0e624cc6c76fbd.tar.gz
plan9port-60535a5ff621d2e0f1eb91a08c0e624cc6c76fbd.tar.bz2
plan9port-60535a5ff621d2e0f1eb91a08c0e624cc6c76fbd.zip
make work with new thread library
Diffstat (limited to 'src/cmd/9term/win.c')
-rw-r--r--src/cmd/9term/win.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c
index a92c1656..d471f987 100644
--- a/src/cmd/9term/win.c
+++ b/src/cmd/9term/win.c
@@ -110,6 +110,20 @@ waitthread(void *v)
}
void
+hangupnote(void *a, char *msg)
+{
+ if(strcmp(msg, "hangup") == 0 && pid != 0){
+ postnote(PNGROUP, pid, "hangup");
+ noted(NDFLT);
+ }
+ if(strstr(msg, "child")){
+ /* bug: do better */
+ threadexitsall(0);
+ }
+ noted(NDFLT);
+}
+
+void
threadmain(int argc, char **argv)
{
int fd, id;
@@ -140,7 +154,10 @@ threadmain(int argc, char **argv)
}
}
- threadnotify(nopipes, 1);
+ notedisable("sys: write on closed pipe");
+ noteenable("sys: child");
+ notify(hangupnote);
+
if((fs = nsmount("acme", "")) == 0)
sysfatal("nsmount acme: %r");
ctlfd = fsopen(fs, "new/ctl", ORDWR|OCEXEC);
@@ -184,7 +201,7 @@ threadmain(int argc, char **argv)
fswrite(ctlfd, buf, strlen(buf));
updatewinsize(25, 80, 0, 0);
- threadcreate(stdoutproc, nil, STACK);
+ proccreate(stdoutproc, nil, STACK);
stdinproc(nil);
}
@@ -420,13 +437,12 @@ stdoutproc(void *v)
char x[16], hold[UTFmax];
USED(v);
- threadnotify(nopipes, 1);
buf = malloc(8192+UTFmax+1);
npart = 0;
for(;;){
/* Let typing have a go -- maybe there's a rubout waiting. */
yield();
- n = threadread(fd1, buf+npart, 8192);
+ n = read(fd1, buf+npart, 8192);
if(n < 0)
error(nil);
if(n == 0)