How close does the timing have to be? Do you know the pid of the process you
want to wait for?
If you know the pid, then try using the getpgid(2) function. You pass it a
pid and it returns the progess group id of the target pid, but more
importantly it will return -1 and set errno to ESRCH if the pid is no longer
in memory. You may have to run this from root either root or as the owner of
the pid that you are trying to detect - the man page leads me to believe
that you might get an EPERM if you try to access another account's
processes.
If you know that a particular process ignores a specific signal and if you
are priviledged to send a signal to that process (same conditions above,
either you own it or you are root), then use kill(2) or sigsend(2) to send
the ignored signal. Again, you'll get an ESRCH.
I'd strongly advise against puting this in a real tight loop or else your
consume a lot of cpu. If your timing is not critical, use SIGALRM to set a
timer and then check the target pid.
Ken
> Just a quick question - I can't see this in the FAQ, and I think it's a
> simple yes or no (in fact, I think it's no).
> Is there a function like waitpid() that will block until a specified
> process exits? waitpid() will only do this if the calling process is the
> parent of the specified process.
> Tom Cowell