ref: 13c8ff13ac27366573699e1690d91640d99f1b79
parent: 1c5ddd7dc3c63b456fca3db28174d675dc7928b8
author: qwx <qwx@sciops.net>
date: Sun Oct 30 18:02:08 EDT 2022
follow play(1)'s example and assert dominance if in the end this doesn't really help, it'll be removed
--- a/pplay.c
+++ b/pplay.c
@@ -29,6 +29,24 @@
return p;
}
+static int
+setpri(int pri)
+{
+ int n, fd, pid;
+ char path[32];
+
+ if((pid = getpid()) == 0)
+ return -1;
+ snprint(path, sizeof path, "/proc/%d/ctl", pid);
+ if((fd = open(path, OWRITE)) < 0)
+ return -1;
+ n = fprint(fd, "pri %d\n", pri);
+ close(fd);
+ if(n < 0)
+ return -1;
+ return 0;
+}
+
static void
athread(void *)
{
@@ -124,7 +142,6 @@
filesz = ofs;
reallocbuf(filesz);
nsamp = filesz / 4;
- close(fd);
}
static void
@@ -151,6 +168,7 @@
if((fd = *argv != nil ? open(*argv, OREAD) : 0) < 0)
sysfatal("open: %r");
initbuf(fd);
+ close(fd);
initdrw();
if((kc = initkeyboard(nil)) == nil)
sysfatal("initkeyboard: %r");
@@ -164,6 +182,8 @@
{nil, nil, CHANEND}
};
initcmd();
+ if(setpri(13) < 0)
+ fprint(2, "setpri: %r\n");
toggleplay();
for(;;){
switch(alt(a)){