ref: fc997ae15d01418e6540b200474fa66eb191a616
parent: b5f269b1312d2643de9d1c9553b3715c21cb7122
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Mar 8 10:11:23 EDT 2020
devproc: return process id when reading /proc/n/ctl file allow reading the control file of a process and return its pid number. if the process has exited, return an error. this can be usefull as a way to test if a process is still alive. and also makes it behave similar to network protocol directories. another side effect is that processes who erroneously open the ctl file ORDWR would be allowed todo so as along as they have write permission and the process is not a kernel process.
--- a/sys/src/9/port/devproc.c
+++ b/sys/src/9/port/devproc.c
@@ -442,6 +442,7 @@
error(Eperm);
break;
+ case Qctl:
case Qargs:
case Qwait:
case Qnoteid:
@@ -458,11 +459,6 @@
pid = p->noteid;
break;
- case Qctl:
- if(p->kp || omode != OWRITE)
- error(Eperm);
- break;
-
case Qmem:
case Qregs:
case Qfpregs:
@@ -945,6 +941,9 @@
}
}
error(Ebadarg);
+
+ case Qctl:
+ return readnum(offset, va, n, p->pid, NUMSIZE);
case Qnoteid:
return readnum(offset, va, n, p->noteid, NUMSIZE);
--
⑨