From: Kenny McCormack on
In article <73b1cbc4-74d4-4c0a-b2d6-e7de203bd170(a)o30g2000yqb.googlegroups.com>,
David Schwartz <davids(a)webmaster.com> wrote:
>On Apr 8, 7:57�am, Sasha <agal...(a)audible.com> wrote:
>
>> I need to wait for already running process to track when it exits. I
>> know how to do this for the child process spawned by the watcher
>> process, I need now to do the same for the process already running.
>
>What's your outer problem? Why do you care whether this particular
>process is still running or not?
>
>There's a strong chance there's a good solution to your problem, but
>you're still telling us how you think it should be solved. We need to
>know what the actual problem is.

It's not that hard to imagine this need. I've had to do similar many
times. So, I don't think there is any reason to keep harassing him for
details.

You are right that traditional Unix doesn't have this ability, but the
fact is that modern systems (like Windows) do have the ability, as does
modern Unix (via ptrace() and similar).

It is also probable that something could be done with the /proc
filesystem under Linux (and simialr under other OSes, e.g., Solaris). I
would imagine that if you did an open() on, say, /proc/self/<pid>/environ,
and kept that file open, something interesting might happen when the
process exited. I haven't researched this, though - and have no plans
to unless/until such a need appears in my life.

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

From: David Schwartz on
On Apr 8, 9:58 am, gaze...(a)shell.xmission.com (Kenny McCormack) wrote:

> >There's a strong chance there's a good solution to your problem, but
> >you're still telling us how you think it should be solved. We need to
> >know what the actual problem is.

> It's not that hard to imagine this need.

It's not that I can't imagine how one could need this. It's that I
don't know why this particular person needs this.

> I've had to do similar many
> times.

Me too, and for different reasons. And the different problems had
different solutions.

> So, I don't think there is any reason to keep harassing him for
> details.

If I get the details, I can find the right solution. Without them, I
can't.

DS
From: Ian Collins on
On 04/ 9/10 03:02 AM, Rainer Weikusat wrote:
> Sasha<agalkin(a)audible.com> writes:
>
> [...]
>
>> I need to wait for already running process to track when it exits. I
>> know how to do this for the child process spawned by the watcher
>> process, I need now to do the same for the process already running.
>
> "man ptrace"

Do some platforms extend ptrace to control non-child processes?

--
Ian Collins
From: Ersek, Laszlo on
On Fri, 9 Apr 2010, Ian Collins wrote:

> On 04/ 9/10 03:02 AM, Rainer Weikusat wrote:
>> Sasha<agalkin(a)audible.com> writes:
>>
>> [...]
>>
>>> I need to wait for already running process to track when it exits. I
>>> know how to do this for the child process spawned by the watcher
>>> process, I need now to do the same for the process already running.
>>
>> "man ptrace"
>
> Do some platforms extend ptrace to control non-child processes?

Absolutely; you can attach gdb to an already running, unrelated process.

lacos
From: Ian Collins on
On 04/ 9/10 10:21 AM, Ersek, Laszlo wrote:
> On Fri, 9 Apr 2010, Ian Collins wrote:
>
>> On 04/ 9/10 03:02 AM, Rainer Weikusat wrote:
>>> Sasha<agalkin(a)audible.com> writes:
>>>
>>> [...]
>>>
>>>> I need to wait for already running process to track when it exits. I
>>>> know how to do this for the child process spawned by the watcher
>>>> process, I need now to do the same for the process already running.
>>>
>>> "man ptrace"
>>
>> Do some platforms extend ptrace to control non-child processes?
>
> Absolutely; you can attach gdb to an already running, unrelated process.
>
OK, thanks. The online Linux man page
(http://linux.die.net/man/2/ptrace) was a little ambiguous:

"The ptrace() system call provides a means by which a parent process may
observe and control the execution of another process"

Note the use of parent and another rather parent and child.

--
Ian Collins