Path: utzoo!utgpu!water!watmath!clyde!ima!minya!jc From: jc@minya.UUCP (John Chambers) Newsgroups: comp.unix.wizards Subject: Is processalive? Message-ID: <429@minya.UUCP> Date: 10 Dec 87 03:40:49 GMT References: <1454@rtech.UUCP> <1921@munnari.oz> Organization: home Lines: 32 > > On SV, non-root users may kill(2) processes having the same uid and > > their children. > > > > On BSD, non-root users may only kill(2) processes having the same uid > > (modulo the setpgrp bug recently mentioned in this group.). This makes > > it awkward to kill setuid subprocesses. This reminds me of a question I'd like to pose to all the wizards out there. Is there a universal way that will work on any Unix to write a function isprocess(n) which returns TRUE if process n is alive, and FALSE if it isn't alive? Note that I have said nothing about the relationship of process n (if it exists) to the process that is asking. They might or might not be related. They might or might not have the same uid and gid. I don't want to kill the process (or even upset it in any way). I just want to know if it is alive. On this SysV, this can be done (with some difficulty) by doing a kill(0,n), which doesn't actually do anything to the process (as far as I can tell), but it does return different values in errno for no-such-process and for wrong-uid. I.e., you can examine the return value (0 or -1) and errno, and from them you can determine whether the process exists or not. So far, I haven't tried to solve the problem on BSD, but the above remark implies that my SysV code won't work. It'd be useful to have a portable subroutine (presumably with an #ifdef or three) to answer this question. -- John Chambers <{adelie,ima,maynard,mit-eddie}!minya!{jc,root}> (617/484-6393)