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.
This commit is contained in:
parent
57741d473f
commit
a609c1a2f8
1 changed files with 4 additions and 5 deletions
|
@ -442,6 +442,7 @@ procopen(Chan *c, int omode0)
|
|||
error(Eperm);
|
||||
break;
|
||||
|
||||
case Qctl:
|
||||
case Qargs:
|
||||
case Qwait:
|
||||
case Qnoteid:
|
||||
|
@ -458,11 +459,6 @@ procopen(Chan *c, int omode0)
|
|||
pid = p->noteid;
|
||||
break;
|
||||
|
||||
case Qctl:
|
||||
if(p->kp || omode != OWRITE)
|
||||
error(Eperm);
|
||||
break;
|
||||
|
||||
case Qmem:
|
||||
case Qregs:
|
||||
case Qfpregs:
|
||||
|
@ -946,6 +942,9 @@ procread(Chan *c, void *va, long n, vlong off)
|
|||
}
|
||||
error(Ebadarg);
|
||||
|
||||
case Qctl:
|
||||
return readnum(offset, va, n, p->pid, NUMSIZE);
|
||||
|
||||
case Qnoteid:
|
||||
return readnum(offset, va, n, p->noteid, NUMSIZE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue