summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/src/cmd/rio/dat.h1
-rw-r--r--sys/src/cmd/rio/fsys.c8
-rw-r--r--sys/src/cmd/rio/rio.c5
-rw-r--r--sys/src/cmd/rio/scrl.c24
-rw-r--r--sys/src/cmd/rio/wind.c37
-rw-r--r--sys/src/cmd/rio/xfid.c6
6 files changed, 42 insertions, 39 deletions
diff --git a/sys/src/cmd/rio/dat.h b/sys/src/cmd/rio/dat.h
index 5680a303a..363be0256 100644
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -172,7 +172,6 @@ struct Window
uchar mouseopen;
uchar kbdopen;
char *label;
- int pid;
char *dir;
};
diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c
index b141055d3..1676ef1f9 100644
--- a/sys/src/cmd/rio/fsys.c
+++ b/sys/src/cmd/rio/fsys.c
@@ -96,7 +96,7 @@ post(char *name, char *envname, int srvfd)
fd = create(name, OWRITE|ORCLOSE|OCEXEC, 0600);
if(fd < 0)
error(name);
- sprint(buf, "%d",srvfd);
+ snprint(buf, sizeof(buf), "%d", srvfd);
if(write(fd, buf, strlen(buf)) != strlen(buf))
error("srv write");
putenv(envname, name);
@@ -150,7 +150,7 @@ filsysinit(Channel *cxfidalloc)
*/
if(cexecpipe(&p0, &wctlfd) < 0)
goto Rescue;
- sprint(srvwctl, "/srv/riowctl.%s.%d", fs->user, pid);
+ snprint(srvwctl, sizeof(srvwctl), "/srv/riowctl.%s.%d", fs->user, pid);
post(srvwctl, "wctl", p0);
close(p0);
@@ -167,7 +167,7 @@ filsysinit(Channel *cxfidalloc)
/*
* Post srv pipe
*/
- sprint(srvpipe, "/srv/rio.%s.%d", fs->user, pid);
+ snprint(srvpipe, sizeof(srvpipe), "/srv/rio.%s.%d", fs->user, pid);
post(srvpipe, "wsys", fs->cfd);
return fs;
@@ -537,7 +537,7 @@ filsysread(Filsys *fs, Xfid *x, Fid *f)
int i, n, o, e, len, j, k, *ids;
Dirtab *d, dt;
uint clock;
- char buf[16];
+ char buf[32];
if((f->qid.type & QTDIR) == 0){
sendp(x->c, xfidread);
diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c
index 2e91e3413..119117c93 100644
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -45,7 +45,6 @@ void initcmd(void*);
Channel* initkbd(void);
char *fontname;
-int mainpid;
enum
{
@@ -159,7 +158,6 @@ threadmain(int argc, char *argv[])
break;
}ARGEND
- mainpid = getpid();
if(getwd(buf, sizeof buf) == nil)
startdir = estrdup(".");
else
@@ -333,7 +331,8 @@ killprocs(void)
int i;
for(i=0; i<nwindow; i++)
- postnote(PNGROUP, window[i]->pid, "hangup");
+ if(window[i]->notefd >= 0)
+ write(window[i]->notefd, "hangup", 6);
}
void
diff --git a/sys/src/cmd/rio/scrl.c b/sys/src/cmd/rio/scrl.c
index 4edbd66e4..1bd64899e 100644
--- a/sys/src/cmd/rio/scrl.c
+++ b/sys/src/cmd/rio/scrl.c
@@ -13,24 +13,25 @@
static Image *scrtmp;
static
-void
+Image*
scrtemps(void)
{
int h;
- if(scrtmp)
- return;
- h = BIG*Dy(screen->r);
- scrtmp = allocimage(display, Rect(0, 0, 32, h), screen->chan, 0, DNofill);
- if(scrtmp == nil)
- error("scrtemps");
+ if(scrtmp == nil){
+ h = BIG*Dy(screen->r);
+ scrtmp = allocimage(display, Rect(0, 0, 32, h), screen->chan, 0, DNofill);
+ }
+ return scrtmp;
}
void
freescrtemps(void)
{
- freeimage(scrtmp);
- scrtmp = nil;
+ if(scrtmp){
+ freeimage(scrtmp);
+ scrtmp = nil;
+ }
}
static
@@ -68,11 +69,10 @@ wscrdraw(Window *w)
Rectangle r, r1, r2;
Image *b;
- scrtemps();
- if(w->i == nil)
+ b = scrtemps();
+ if(b == nil || w->i == nil)
return;
r = w->scrollr;
- b = scrtmp;
r1 = r;
r1.min.x = 0;
r1.max.x = Dx(r);
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 259626486..b45a3624d 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -70,7 +70,7 @@ wsetname(Window *w)
int i, n;
char err[ERRMAX];
- n = sprint(w->name, "window.%d.%d", w->id, w->namecount++);
+ n = snprint(w->name, sizeof(w->name)-2, "window.%d.%d", w->id, w->namecount++);
for(i='A'; i<='Z'; i++){
if(nameimage(w->i, w->name, 1) > 0)
return;
@@ -446,6 +446,7 @@ interruptproc(void *v)
notefd = v;
write(*notefd, "interrupt", 9);
+ close(*notefd);
free(notefd);
}
@@ -672,7 +673,7 @@ wkeyctl(Window *w, Rune r)
w->qh = w->nr;
wshow(w, w->qh);
notefd = emalloc(sizeof(int));
- *notefd = w->notefd;
+ *notefd = dup(w->notefd, -1);
proccreate(interruptproc, notefd, 4096);
return;
case Kack: /* ^F: file name completion */
@@ -838,7 +839,7 @@ wplumb(Window *w)
p0--;
while(p1<w->nr && w->r[p1]!=' ' && w->r[p1]!='\t' && w->r[p1]!='\n')
p1++;
- sprint(buf, "click=%d", w->q0-p0);
+ snprint(buf, sizeof(buf), "click=%d", w->q0-p0);
m->attr = plumbunpackattr(buf);
}
if(p1-p0 > messagesize-1024){
@@ -1088,6 +1089,7 @@ wctlmesg(Window *w, int m, Rectangle r, Image *i)
strcpy(buf, w->name);
wresize(w, i, m==Moved);
proccreate(deletetimeoutproc, estrdup(buf), 4096);
+ flushimage(display, 1);
break;
case Refresh:
if(w->deleted || Dx(w->screenr)<=0 || !rectclip(&r, w->i->r) || w->mouseopen)
@@ -1335,20 +1337,23 @@ wclosewin(Window *w)
void
wsetpid(Window *w, int pid, int dolabel)
{
- char buf[128];
- int fd;
-
- w->pid = pid;
- if(dolabel){
- sprint(buf, "rc %d", pid);
- free(w->label);
- w->label = estrdup(buf);
+ char buf[64];
+ int ofd;
+
+ ofd = w->notefd;
+ if(pid <= 0)
+ w->notefd = -1;
+ else {
+ if(dolabel){
+ snprint(buf, sizeof(buf), "rc %d", pid);
+ free(w->label);
+ w->label = estrdup(buf);
+ }
+ snprint(buf, sizeof(buf), "/proc/%d/notepg", pid);
+ w->notefd = open(buf, OWRITE|OCEXEC);
}
- sprint(buf, "/proc/%d/notepg", pid);
- fd = open(buf, OWRITE|OCEXEC);
- if(w->notefd > 0)
- close(w->notefd);
- w->notefd = fd;
+ if(ofd >= 0)
+ close(ofd);
}
void
diff --git a/sys/src/cmd/rio/xfid.c b/sys/src/cmd/rio/xfid.c
index cc4edee92..acd61c8ac 100644
--- a/sys/src/cmd/rio/xfid.c
+++ b/sys/src/cmd/rio/xfid.c
@@ -554,8 +554,8 @@ xfidwrite(Xfid *x)
break;
default:
- fprint(2, buf, "unknown qid %d in write\n", qid);
- sprint(buf, "unknown qid in write");
+ fprint(2, "unknown qid %d in write\n", qid);
+ snprint(buf, sizeof(buf), "unknown qid in write");
filsysrespond(x->fs, x, &fc, buf);
return;
}
@@ -892,7 +892,7 @@ xfidread(Xfid *x)
default:
fprint(2, "unknown qid %d in read\n", qid);
- sprint(buf, "unknown qid in read");
+ snprint(buf, sizeof(buf), "unknown qid in read");
filsysrespond(x->fs, x, &fc, buf);
break;
}