aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/9p.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-10-22 17:05:24 +0000
committerrsc <devnull@localhost>2004-10-22 17:05:24 +0000
commit3e6107910ecbf6034ec277a8b181d27a3033a0fa (patch)
treefebdc653d5146de90bf15824c54297b31c8f2848 /src/cmd/9p.c
parentd371199605e09d56b95de00e9866cf4fea2d8615 (diff)
downloadplan9port-3e6107910ecbf6034ec277a8b181d27a3033a0fa.tar.gz
plan9port-3e6107910ecbf6034ec277a8b181d27a3033a0fa.tar.bz2
plan9port-3e6107910ecbf6034ec277a8b181d27a3033a0fa.zip
exit 9p on interrupt signal. should do better job here.
Diffstat (limited to 'src/cmd/9p.c')
-rw-r--r--src/cmd/9p.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/9p.c b/src/cmd/9p.c
index e6646b7d..9a5aa67c 100644
--- a/src/cmd/9p.c
+++ b/src/cmd/9p.c
@@ -1,4 +1,5 @@
#include <u.h>
+#include <signal.h>
#include <libc.h>
#include <fcall.h>
#include <fs.h>
@@ -54,6 +55,8 @@ threadmain(int argc, char **argv)
usage();
}ARGEND
+ signal(SIGINT, SIG_DFL);
+
if(argc < 1)
usage();
@@ -180,7 +183,7 @@ void
xwrite(int argc, char **argv)
{
char buf[1024];
- int n;
+ int n, did;
Fid *fid;
ARGBEGIN{
@@ -191,10 +194,17 @@ xwrite(int argc, char **argv)
if(argc != 1)
usage();
+ did = 0;
fid = xopen(argv[0], OWRITE|OTRUNC);
- while((n = read(0, buf, sizeof buf)) > 0)
+ while((n = read(0, buf, sizeof buf)) > 0){
+ did = 1;
if(fswrite(fid, buf, n) != n)
sysfatal("write error: %r");
+ }
+ if(n == 0 && !did){
+ if(fswrite(fid, buf, 0) != 0)
+ sysfatal("write error: %r");
+ }
if(n < 0)
sysfatal("read error: %r");
exits(0);