]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/cpu.c
cc: use 7 octal digits for 21 bit runes
[plan9front.git] / sys / src / cmd / cpu.c
index 1994aaf282be381d4ff6823d1fcad69fa986d976..d38d717404efc74cdc18832ef55ca6b91cd29946 100644 (file)
@@ -116,31 +116,6 @@ procgetname(void)
        return strdup(lp+1);
 }
 
-/*
- * based on libthread's threadsetname, but drags in less library code.
- * actually just sets the arguments displayed.
- */
-void
-procsetname(char *fmt, ...)
-{
-       int fd;
-       char *cmdname;
-       char buf[128];
-       va_list arg;
-
-       va_start(arg, fmt);
-       cmdname = vsmprint(fmt, arg);
-       va_end(arg);
-       if (cmdname == nil)
-               return;
-       snprint(buf, sizeof buf, "#p/%d/args", getpid());
-       if((fd = open(buf, OWRITE)) >= 0){
-               write(fd, cmdname, strlen(cmdname)+1);
-               close(fd);
-       }
-       free(cmdname);
-}
-
 void
 main(int argc, char **argv)
 {
@@ -152,7 +127,7 @@ main(int argc, char **argv)
        origargs = procgetname();
        /* see if we should use a larger message size */
        fd = open("/dev/draw", OREAD);
-       if(fd > 0){
+       if(fd >= 0){
                ms = iounit(fd);
                if(msgsize < ms+IOHDRSZ)
                        msgsize = ms+IOHDRSZ;
@@ -198,7 +173,7 @@ main(int argc, char **argv)
                *s++ = '!';
                *s = 0;
                while(p = ARGF())
-                       s = seprint(s, cmd+sizeof(cmd), " %s", p);
+                       s = seprint(s, cmd+sizeof(cmd), " %q", p);
                break;
        case 'k':
                keyspec = smprint("%s %s", keyspec, EARGF(usage()));
@@ -783,10 +758,8 @@ rmtnoteproc(void)
                _exits(0);
        case 0:
                fd = open(rmtnotefile, OREAD);
-               if(fd < 0){
-                       syslog(0, "cpu", "cpu -R: can't open %s", rmtnotefile);
+               if(fd < 0)
                        _exits(0);
-               }
        
                for(;;){
                        n = read(fd, buf, sizeof(buf)-1);
@@ -1028,14 +1001,7 @@ notefs(int fd)
        ncpunote = 0;
        for(;;){
                n = read9pmsg(fd, buf, sizeof(buf));
-               if(n < 0){
-                       if(dbg)
-                               fprint(2, "read9pmsg(%d) returns %d: %r\n", fd, n);
-                       break;
-               }
-               if(n == 0)
-                       continue;
-               if(convM2S(buf, n, &f) <= BIT16SZ)
+               if(n <= 0 || convM2S(buf, n, &f) != n)
                        break;
                if(dbg)
                        fprint(2, "notefs: ->%F\n", &f);