How do I check if a pid is running?

Donn Cave donn at drizzle.com
Wed May 15 01:22:22 EDT 2002


Quoth "Noah Spurrier" <noah at noah.org>:
| Yes, indeed, UNIX is a dark and grotty operating system.
| It's filled with things like this.
|
| What I find particularly amusing is the fact that while
| POSIX.2 defines a standard for a command line
| process status (ps), POSIX.1 does not define a standard
| for a system call to get process status.
| Thus it seems that the only portable way to get a process status
| is to do a system call to the 'ps' command line utility.
| The fact that nobody really fully complies with POSIX seems 
| to make this whole notion of portability a cruel joke anyway.

Well, POSIX.1 is not the most comprehensive standard, and there
are some especially grievous flaws (e.g., filesystem locking
semantics, and a pervasive use of unsigned integers for counting),
but on the bright side, its restricted domain allows some platforms
(like DEC VMS) to support it that couldn't pass for real UNIX.

A UNIX platform should shoot for the X/Open standard.  Don't know
if that addresses kill(..., 0), though.

| I can't imagine anyone coming out with a truly new OS.

Oh yeah they are, certainly more than enough to meet the
demand for them.  Not infrequently they'll support POSIX
and X/Open APIs though, at least a significant subset -
leveraging a lot of software development.

| It's like the QWERTY keyboard. After a while you are
| committed and eventually society becomes stuck on a
| standard that was more of a historical accident that
| a work planning and engineering.
|
| But this is what makes UNIX more fun than Windows.
| I actually get quite a bit of pleasure at figuring this stuff out.

There isn't a historical legacy in Windows?

| Of course, that whole "kill (pid, 0)" thing turned out 
| not to work very well anyway. It's very platform dependent.
| It worked on every platform except the one I needed it to work on.

That's odd.  Works on BeOS, for what it's worth.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list