From: Sasha on
Is there way on UNIX to wait for particular process (not child
process) identified by pid? I know how to wait for a child process but
is there way to wait for not child process?
From: David Schwartz on
On Apr 7, 3:45 pm, Sasha <agal...(a)audible.com> wrote:

> Is there way on UNIX to wait for particular process (not child
> process) identified by pid? I know how to wait for a child process but
> is there way to wait for not child process?

There's no way. But there's likely a good way to solve whatever
problem you have. Waiting for a process that's not your child,
however, is not the solution.

DS
From: Ian Collins on
On 04/ 8/10 10:45 AM, Sasha wrote:
> Is there way on UNIX to wait for particular process (not child
> process) identified by pid? I know how to wait for a child process but
> is there way to wait for not child process?

You can't.

The closest you can get would be to poll the process with

kill( pid, 0 );

assuming the pid isn't reused too quickly.

Why would you want to?

--
Ian Collins
From: Sasha on
On Apr 7, 8:01 pm, Ian Collins <ian-n...(a)hotmail.com> wrote:
> On 04/ 8/10 10:45 AM, Sasha wrote:
>
> > Is there way on UNIX to wait for particular process (not child
> > process) identified by pid? I know how to wait for a child process but
> > is there way to wait for not child process?
>
> You can't.
>
> The closest you can get would be to poll the process with
>
> kill( pid, 0 );
>
> assuming the pid isn't reused too quickly.
>
> Why would you want to?
>
> --
> Ian Collins

I need to watch a particular already running process until it exists.
On Windows I would call OpenPorocess to get the process handle and
then use WaitForSingleObject to wait on the handle. I wonder why UNIX
does not have something similar?
From: Ian Collins on
On 04/ 8/10 02:28 PM, Sasha wrote:
> On Apr 7, 8:01 pm, Ian Collins<ian-n...(a)hotmail.com> wrote:
>> On 04/ 8/10 10:45 AM, Sasha wrote:
>>
>>> Is there way on UNIX to wait for particular process (not child
>>> process) identified by pid? I know how to wait for a child process but
>>> is there way to wait for not child process?
>>
>> You can't.
>>
>> The closest you can get would be to poll the process with
>>
>> kill( pid, 0 );
>>
>> assuming the pid isn't reused too quickly.
>>
>> Why would you want to?
>>
[best not to quote sigs]
>
> I need to watch a particular already running process until it exists.
> On Windows I would call OpenPorocess to get the process handle and
> then use WaitForSingleObject to wait on the handle. I wonder why UNIX
> does not have something similar?

Probably because it's seldom needed. The process that's normally
interested in waiting for another to exit is the parent processes. On
that basis, you could spawn the process of interest and have to parent
signal you when the child completes.

What exactly are you trying to achieve? There's probably a better way
if you provide some more information.

--
Ian Collins