aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9pfuse
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-04-17 16:03:49 -0400
committerRuss Cox <rsc@swtch.com>2008-04-17 16:03:49 -0400
commite63025d09486aea0f644578b5e05a093c130b7d2 (patch)
tree09a2c4e6e2ffdbb93eed03dcc286096380599ba2 /src/cmd/9pfuse
parent14125803572e1fa6efb2badf4a41e2e59e81a76d (diff)
downloadplan9port-e63025d09486aea0f644578b5e05a093c130b7d2.tar.gz
plan9port-e63025d09486aea0f644578b5e05a093c130b7d2.tar.bz2
plan9port-e63025d09486aea0f644578b5e05a093c130b7d2.zip
9pfuse: accept - for stdin, try to hang up cleanly
Diffstat (limited to 'src/cmd/9pfuse')
-rw-r--r--src/cmd/9pfuse/a.h1
-rw-r--r--src/cmd/9pfuse/main.c24
2 files changed, 21 insertions, 4 deletions
diff --git a/src/cmd/9pfuse/a.h b/src/cmd/9pfuse/a.h
index aaec3ef0..f5038e16 100644
--- a/src/cmd/9pfuse/a.h
+++ b/src/cmd/9pfuse/a.h
@@ -3,6 +3,7 @@
#include <sys/stat.h>
#include <sys/uio.h>
#include <sys/socket.h>
+#include <sys/select.h>
#include <libc.h>
#include <fcall.h>
#include <thread.h>
diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c
index 50c835bb..fa27cb9c 100644
--- a/src/cmd/9pfuse/main.c
+++ b/src/cmd/9pfuse/main.c
@@ -39,7 +39,6 @@
# endif
#endif
-
int debug;
char *argv0;
char *aname = "";
@@ -77,6 +76,7 @@ usage(void)
}
void fusereader(void*);
+void watchfd(void*);
void
threadmain(int argc, char **argv)
@@ -139,8 +139,12 @@ init9p(char *addr, char *spec)
{
int fd;
- if((fd = dial(netmkaddr(addr, "tcp", "564"), nil, nil, nil)) < 0)
- sysfatal("dial %s: %r", addr);
+ if(strcmp(addr, "-") == 0)
+ fd = 0;
+ else
+ if((fd = dial(netmkaddr(addr, "tcp", "564"), nil, nil, nil)) < 0)
+ sysfatal("dial %s: %r", addr);
+ proccreate(watchfd, (void*)(uintptr)fd, STACK);
if((fsys = fsmount(fd, spec)) == nil)
sysfatal("fsmount: %r");
fsysroot = fsroot(fsys);
@@ -1208,4 +1212,16 @@ estrdup(char *p)
return pp;
}
-
+void
+watchfd(void *v)
+{
+ int fd = (int)(uintptr)v;
+
+ /* wait for exception (file closed) */
+ fd_set set;
+ FD_ZERO(&set);
+ FD_SET(fd, &set);
+ if(select(fd+1, NULL, NULL, &set, NULL) >= 0)
+ threadexitsall(nil);
+ return;
+}