public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* inotify and /proc/<pid>
@ 2007-07-31  2:16 Joseph Pingenot
  2007-07-31  3:17 ` Al Viro
  0 siblings, 1 reply; 16+ messages in thread
From: Joseph Pingenot @ 2007-07-31  2:16 UTC (permalink / raw)
  To: linux-kernel

I was trying to use inotify to watch process changes (especially process
  termination) by watching /proc/<pid>.

Sadly, although I could see something reading various files, nothing
  was issued when the process I was watching exited and the directory
  went away.

Is this intentional, or a bug?

-Joseph
-- 
trelane@digitasaru.net.///////////////////////////////////////////////
"There is also an entire branch in the physical therapy field dedicated
 to the treatment of little-finger injuries caused by excessive Emacs
 use."  --Linux Weekly News editor (http://lwn.net/Articles/206916/)
///////260 IATL / The University of Iowa / Iowa City, IA  52242///////

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  2:16 inotify and /proc/<pid> Joseph Pingenot
@ 2007-07-31  3:17 ` Al Viro
  2007-07-31  3:25   ` Joseph Pingenot
  0 siblings, 1 reply; 16+ messages in thread
From: Al Viro @ 2007-07-31  3:17 UTC (permalink / raw)
  To: linux-kernel

On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
> I was trying to use inotify to watch process changes (especially process
>   termination) by watching /proc/<pid>.
> 
> Sadly, although I could see something reading various files, nothing
>   was issued when the process I was watching exited and the directory
>   went away.
> 
> Is this intentional, or a bug?

It's a bug you intend to introduce in your program...  IOW, don't
do that.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:17 ` Al Viro
@ 2007-07-31  3:25   ` Joseph Pingenot
  2007-07-31  3:31     ` Joseph Pingenot
                       ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Joseph Pingenot @ 2007-07-31  3:25 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

>From Al Viro on Tuesday, 31 July, 2007:
>On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
>> I was trying to use inotify to watch process changes (especially process
>>   termination) by watching /proc/<pid>.
>> Sadly, although I could see something reading various files, nothing
>>   was issued when the process I was watching exited and the directory
>>   went away.
>> Is this intentional, or a bug?
>It's a bug you intend to introduce in your program...  IOW, don't
>do that.

More background, please?

What's the way to check for a process exiting without spinning?

-Joseph

-- 
trelane@digitasaru.net.///////////////////////////////////////////////
"There is also an entire branch in the physical therapy field dedicated
 to the treatment of little-finger injuries caused by excessive Emacs
 use."  --Linux Weekly News editor (http://lwn.net/Articles/206916/)
///////260 IATL / The University of Iowa / Iowa City, IA  52242///////

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:25   ` Joseph Pingenot
@ 2007-07-31  3:31     ` Joseph Pingenot
  2007-07-31  3:36       ` Al Viro
  2007-07-31  3:31     ` Al Viro
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Joseph Pingenot @ 2007-07-31  3:31 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

>From Joseph Pingenot on Monday, 30 July, 2007:
>From Al Viro on Tuesday, 31 July, 2007:
>>On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
>>> I was trying to use inotify to watch process changes (especially process
>>>   termination) by watching /proc/<pid>.
>>> Sadly, although I could see something reading various files, nothing
>>>   was issued when the process I was watching exited and the directory
>>>   went away.
>>> Is this intentional, or a bug?
>>It's a bug you intend to introduce in your program...  IOW, don't
>>do that.
>More background, please?
>What's the way to check for a process exiting without spinning?

I should also specify that the process being waited on is not a
  child process-it's just some other process on the system.

-- 
trelane@digitasaru.net.///////////////////////////////////////////////
"There is also an entire branch in the physical therapy field dedicated
 to the treatment of little-finger injuries caused by excessive Emacs
 use."  --Linux Weekly News editor (http://lwn.net/Articles/206916/)
///////260 IATL / The University of Iowa / Iowa City, IA  52242///////

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:25   ` Joseph Pingenot
  2007-07-31  3:31     ` Joseph Pingenot
@ 2007-07-31  3:31     ` Al Viro
  2007-07-31 15:50     ` Ray Lee
  2007-07-31 18:31     ` Diego Calleja
  3 siblings, 0 replies; 16+ messages in thread
From: Al Viro @ 2007-07-31  3:31 UTC (permalink / raw)
  To: linux-kernel

On Mon, Jul 30, 2007 at 10:25:21PM -0500, Joseph Pingenot wrote:
> >From Al Viro on Tuesday, 31 July, 2007:
> >On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
> >> I was trying to use inotify to watch process changes (especially process
> >>   termination) by watching /proc/<pid>.
> >> Sadly, although I could see something reading various files, nothing
> >>   was issued when the process I was watching exited and the directory
> >>   went away.
> >> Is this intentional, or a bug?
> >It's a bug you intend to introduce in your program...  IOW, don't
> >do that.
> 
> More background, please?
> 
> What's the way to check for a process exiting without spinning?

Depends on what that process is and how it is related to watching
one...

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:31     ` Joseph Pingenot
@ 2007-07-31  3:36       ` Al Viro
  2007-07-31  3:40         ` Joseph Pingenot
  0 siblings, 1 reply; 16+ messages in thread
From: Al Viro @ 2007-07-31  3:36 UTC (permalink / raw)
  To: linux-kernel

On Mon, Jul 30, 2007 at 10:31:13PM -0500, Joseph Pingenot wrote:
> >From Joseph Pingenot on Monday, 30 July, 2007:
> >From Al Viro on Tuesday, 31 July, 2007:
> >>On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
> >>> I was trying to use inotify to watch process changes (especially process
> >>>   termination) by watching /proc/<pid>.
> >>> Sadly, although I could see something reading various files, nothing
> >>>   was issued when the process I was watching exited and the directory
> >>>   went away.
> >>> Is this intentional, or a bug?
> >>It's a bug you intend to introduce in your program...  IOW, don't
> >>do that.
> >More background, please?
> >What's the way to check for a process exiting without spinning?
> 
> I should also specify that the process being waited on is not a
>   child process-it's just some other process on the system.

Umm...  Any details on intended use?  IOW, is that "I want to write
an utility that would wait for given PID to exit, just for the hell
of it" or is there something you are trying to implement using that?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:36       ` Al Viro
@ 2007-07-31  3:40         ` Joseph Pingenot
  2007-07-31  3:48           ` Kyle McMartin
                             ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Joseph Pingenot @ 2007-07-31  3:40 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

>From Al Viro on Tuesday, 31 July, 2007:
>On Mon, Jul 30, 2007 at 10:31:13PM -0500, Joseph Pingenot wrote:
>> >From Joseph Pingenot on Monday, 30 July, 2007:
>> >From Al Viro on Tuesday, 31 July, 2007:
>> >>On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
>> >>> I was trying to use inotify to watch process changes (especially process
>> >>>   termination) by watching /proc/<pid>.
>> >>> Sadly, although I could see something reading various files, nothing
>> >>>   was issued when the process I was watching exited and the directory
>> >>>   went away.
>> >>> Is this intentional, or a bug?
>> >>It's a bug you intend to introduce in your program...  IOW, don't
>> >>do that.
>> >More background, please?
>> >What's the way to check for a process exiting without spinning?
>> I should also specify that the process being waited on is not a
>>   child process-it's just some other process on the system.
>Umm...  Any details on intended use?  IOW, is that "I want to write
>an utility that would wait for given PID to exit, just for the hell
>of it" or is there something you are trying to implement using that?

I'm trying to implement pwait.  It blocks until a specified PID exits,
  and then it exits.

You can use it to do other stuff after a program finishes.

While we're on the subject, is there some way to receive notification
  that some aspect of a process changes (in this case, stopping using
  CPU, but not exiting).

Thanks for the time to help me figure this out.

-Joseph

-- 
trelane@digitasaru.net.///////////////////////////////////////////////
"There is also an entire branch in the physical therapy field dedicated
 to the treatment of little-finger injuries caused by excessive Emacs
 use."  --Linux Weekly News editor (http://lwn.net/Articles/206916/)
///////260 IATL / The University of Iowa / Iowa City, IA  52242///////

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:40         ` Joseph Pingenot
@ 2007-07-31  3:48           ` Kyle McMartin
  2007-07-31  3:50           ` Al Viro
  2007-07-31  5:48           ` Chris Friesen
  2 siblings, 0 replies; 16+ messages in thread
From: Kyle McMartin @ 2007-07-31  3:48 UTC (permalink / raw)
  To: Joseph Pingenot; +Cc: linux-kernel

On Mon, Jul 30, 2007 at 10:40:59PM -0500, Joseph Pingenot wrote:
> From Al Viro on Tuesday, 31 July, 2007:
> >On Mon, Jul 30, 2007 at 10:31:13PM -0500, Joseph Pingenot wrote:
> >> >From Joseph Pingenot on Monday, 30 July, 2007:
> >> >From Al Viro on Tuesday, 31 July, 2007:
> >> >>On Mon, Jul 30, 2007 at 09:16:16PM -0500, Joseph Pingenot wrote:
> >> >>> I was trying to use inotify to watch process changes (especially process
> >> >>>   termination) by watching /proc/<pid>.
> >> >>> Sadly, although I could see something reading various files, nothing
> >> >>>   was issued when the process I was watching exited and the directory
> >> >>>   went away.
> >> >>> Is this intentional, or a bug?
> >> >>It's a bug you intend to introduce in your program...  IOW, don't
> >> >>do that.
> >> >More background, please?
> >> >What's the way to check for a process exiting without spinning?
> >> I should also specify that the process being waited on is not a
> >>   child process-it's just some other process on the system.
> >Umm...  Any details on intended use?  IOW, is that "I want to write
> >an utility that would wait for given PID to exit, just for the hell
> >of it" or is there something you are trying to implement using that?
> 
> I'm trying to implement pwait.  It blocks until a specified PID exits,
>   and then it exits.
>

ptrace with options set to PTRACE_O_TRACEEXIT?

--Kyle

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:40         ` Joseph Pingenot
  2007-07-31  3:48           ` Kyle McMartin
@ 2007-07-31  3:50           ` Al Viro
  2007-07-31  3:56             ` Joseph Pingenot
  2007-07-31  5:48           ` Chris Friesen
  2 siblings, 1 reply; 16+ messages in thread
From: Al Viro @ 2007-07-31  3:50 UTC (permalink / raw)
  To: linux-kernel

On Mon, Jul 30, 2007 at 10:40:59PM -0500, Joseph Pingenot wrote:
> I'm trying to implement pwait.  It blocks until a specified PID exits,
>   and then it exits.

er... ptrace(2)?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:50           ` Al Viro
@ 2007-07-31  3:56             ` Joseph Pingenot
  2007-07-31  4:01               ` Al Viro
  2007-08-01  1:33               ` Valdis.Kletnieks
  0 siblings, 2 replies; 16+ messages in thread
From: Joseph Pingenot @ 2007-07-31  3:56 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel

>From Al Viro on Tuesday, 31 July, 2007:
>On Mon, Jul 30, 2007 at 10:40:59PM -0500, Joseph Pingenot wrote:
>> I'm trying to implement pwait.  It blocks until a specified PID exits,
>>   and then it exits.
>er... ptrace(2)?

Should work for most common usage scenarios, although will suspect that it
  won't for for processes owned by another user (at least, I hope
  it wouldn't).

What is dangerous about inotify on a proc file?

-- 
trelane@digitasaru.net.///////////////////////////////////////////////
"There is also an entire branch in the physical therapy field dedicated
 to the treatment of little-finger injuries caused by excessive Emacs
 use."  --Linux Weekly News editor (http://lwn.net/Articles/206916/)
///////260 IATL / The University of Iowa / Iowa City, IA  52242///////

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:56             ` Joseph Pingenot
@ 2007-07-31  4:01               ` Al Viro
  2007-08-01  1:33               ` Valdis.Kletnieks
  1 sibling, 0 replies; 16+ messages in thread
From: Al Viro @ 2007-07-31  4:01 UTC (permalink / raw)
  To: linux-kernel

On Mon, Jul 30, 2007 at 10:56:27PM -0500, Joseph Pingenot wrote:
> >From Al Viro on Tuesday, 31 July, 2007:
> >On Mon, Jul 30, 2007 at 10:40:59PM -0500, Joseph Pingenot wrote:
> >> I'm trying to implement pwait.  It blocks until a specified PID exits,
> >>   and then it exits.
> >er... ptrace(2)?
> 
> Should work for most common usage scenarios, although will suspect that it
>   won't for for processes owned by another user (at least, I hope
>   it wouldn't).
> 
> What is dangerous about inotify on a proc file?

Playing with the lifetime rules, for starters...

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:40         ` Joseph Pingenot
  2007-07-31  3:48           ` Kyle McMartin
  2007-07-31  3:50           ` Al Viro
@ 2007-07-31  5:48           ` Chris Friesen
  2 siblings, 0 replies; 16+ messages in thread
From: Chris Friesen @ 2007-07-31  5:48 UTC (permalink / raw)
  To: trelane; +Cc: Al Viro, linux-kernel

Joseph Pingenot wrote:

> While we're on the subject, is there some way to receive notification
>   that some aspect of a process changes (in this case, stopping using
>   CPU, but not exiting).

For some internal stuff a while back I did a patch that allows any 
process to register for status change notifications.  Basically, the 
registered process gets put on a list and gets the same notifications 
(killed/stopped/exited, etc.) as the real parent.

Useful for this type of thing.

Chris

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:25   ` Joseph Pingenot
  2007-07-31  3:31     ` Joseph Pingenot
  2007-07-31  3:31     ` Al Viro
@ 2007-07-31 15:50     ` Ray Lee
  2007-07-31 18:31     ` Diego Calleja
  3 siblings, 0 replies; 16+ messages in thread
From: Ray Lee @ 2007-07-31 15:50 UTC (permalink / raw)
  To: trelane, Al Viro, linux-kernel

On 7/30/07, Joseph Pingenot <trelane@digitasaru.net> wrote:
> What's the way to check for a process exiting without spinning?

I think you can get it from the taskstats interface, though I haven't
tried it. See Documentation/accounting/ for details.

Ray

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:25   ` Joseph Pingenot
                       ` (2 preceding siblings ...)
  2007-07-31 15:50     ` Ray Lee
@ 2007-07-31 18:31     ` Diego Calleja
  2007-08-01  0:41       ` Andrew Morton
  3 siblings, 1 reply; 16+ messages in thread
From: Diego Calleja @ 2007-07-31 18:31 UTC (permalink / raw)
  To: trelane; +Cc: Al Viro, linux-kernel

El Mon, 30 Jul 2007 22:25:21 -0500, Joseph Pingenot <trelane@digitasaru.net> escribió:

> More background, please?
> 
> What's the way to check for a process exiting without spinning?


I don't know if it's useful for you, but CONFIG_CONNECTOR and CONFIG_PROC_EVENTS
will report process creation/exit/fork/etc through a netlink interface.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31 18:31     ` Diego Calleja
@ 2007-08-01  0:41       ` Andrew Morton
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Morton @ 2007-08-01  0:41 UTC (permalink / raw)
  To: Diego Calleja; +Cc: trelane, Al Viro, linux-kernel

On Tue, 31 Jul 2007 20:31:49 +0200 Diego Calleja <diegocg@gmail.com> wrote:

> El Mon, 30 Jul 2007 22:25:21 -0500, Joseph Pingenot <trelane@digitasaru.net> escribió:
> 
> > More background, please?
> > 
> > What's the way to check for a process exiting without spinning?
> 
> 
> I don't know if it's useful for you, but CONFIG_CONNECTOR and CONFIG_PROC_EVENTS
> will report process creation/exit/fork/etc through a netlink interface.

yup.  See example code in Documentation/accounting/getdelays.c

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: inotify and /proc/<pid>
  2007-07-31  3:56             ` Joseph Pingenot
  2007-07-31  4:01               ` Al Viro
@ 2007-08-01  1:33               ` Valdis.Kletnieks
  1 sibling, 0 replies; 16+ messages in thread
From: Valdis.Kletnieks @ 2007-08-01  1:33 UTC (permalink / raw)
  To: trelane; +Cc: Al Viro, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Mon, 30 Jul 2007 22:56:27 CDT, Joseph Pingenot said:
> From Al Viro on Tuesday, 31 July, 2007:
> >On Mon, Jul 30, 2007 at 10:40:59PM -0500, Joseph Pingenot wrote:
> >> I'm trying to implement pwait.  It blocks until a specified PID exits,
> >>   and then it exits.
> >er... ptrace(2)?
> 
> Should work for most common usage scenarios, although will suspect that it
>   won't for for processes owned by another user (at least, I hope
>   it wouldn't).
> 
> What is dangerous about inotify on a proc file?

And if it's dangerous, should the inotify system call fail when trying to
set the watch?  Bailout with a -EBADIDEA or something?


[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-08-01  1:33 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-31  2:16 inotify and /proc/<pid> Joseph Pingenot
2007-07-31  3:17 ` Al Viro
2007-07-31  3:25   ` Joseph Pingenot
2007-07-31  3:31     ` Joseph Pingenot
2007-07-31  3:36       ` Al Viro
2007-07-31  3:40         ` Joseph Pingenot
2007-07-31  3:48           ` Kyle McMartin
2007-07-31  3:50           ` Al Viro
2007-07-31  3:56             ` Joseph Pingenot
2007-07-31  4:01               ` Al Viro
2007-08-01  1:33               ` Valdis.Kletnieks
2007-07-31  5:48           ` Chris Friesen
2007-07-31  3:31     ` Al Viro
2007-07-31 15:50     ` Ray Lee
2007-07-31 18:31     ` Diego Calleja
2007-08-01  0:41       ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox