9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] fork/exec and waitpid from another proc
@ 2002-05-10 15:27 rob pike, esq.
  2002-05-10 15:54 ` Latchesar Ionkov
  0 siblings, 1 reply; 5+ messages in thread
From: rob pike, esq. @ 2002-05-10 15:27 UTC (permalink / raw)
  To: 9fans

> I have a threaded process. Proc A executes new program X using fork and exec.
> After the creation proc A continues its work. Procs B and C want to know
> when/if the process X finished. As process X is not child process of B and C
> and they can't wait(2) on it. Proc A has something else to do and doesn't
> care what B and C want.
>
> Is there easy solution for this? In Unix I can use SIGCHLD for proc A to do
> something.

I am still groggy, so maybe I'm missing something, but surely you can use
either the /proc/nnn/wait file or the thread library's `wait channel'.  This
problem sounds just like the one acme has, and it solves it using a wait
channel (grep cpid /sys/src/cmd/acme/*.c or read thread(2)).  The wait
file is described in proc(3).

-rob



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

* Re: [9fans] fork/exec and waitpid from another proc
  2002-05-10 15:27 [9fans] fork/exec and waitpid from another proc rob pike, esq.
@ 2002-05-10 15:54 ` Latchesar Ionkov
  0 siblings, 0 replies; 5+ messages in thread
From: Latchesar Ionkov @ 2002-05-10 15:54 UTC (permalink / raw)
  To: 9fans

On Fri, May 10, 2002 at 11:27:55AM -0400, rob pike, esq. said:
> > I have a threaded process. Proc A executes new program X using fork and exec.
> > After the creation proc A continues its work. Procs B and C want to know
> > when/if the process X finished. As process X is not child process of B and C
> > and they can't wait(2) on it. Proc A has something else to do and doesn't
> > care what B and C want.
> >
> > Is there easy solution for this? In Unix I can use SIGCHLD for proc A to do
> > something.
>
> I am still groggy, so maybe I'm missing something, but surely you can use
> either the /proc/nnn/wait file or the thread library's `wait channel'.  This
> problem sounds just like the one acme has, and it solves it using a wait
> channel (grep cpid /sys/src/cmd/acme/*.c or read thread(2)).  The wait
> file is described in proc(3).

That's what I was looking for. Thanks and sorry for the stupid question.

	Lucho


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

* Re: [9fans] fork/exec and waitpid from another proc
  2002-05-10 11:32 Russ Cox
@ 2002-05-10 14:20 ` Latchesar Ionkov
  0 siblings, 0 replies; 5+ messages in thread
From: Latchesar Ionkov @ 2002-05-10 14:20 UTC (permalink / raw)
  To: 9fans

On Fri, May 10, 2002 at 07:32:56AM -0400, Russ Cox said:
> > I have a threaded process. Proc A executes new program X using fork and exec.
> > After the creation proc A continues its work. Procs B and C want to know
> > when/if the process X finished. As process X is not child process of B and C
> > and they can't wait(2) on it. Proc A has something else to do and doesn't
> > care what B and C want.
>
> as you have described it, no.
>
> but you could introduce yet another proc:
>
> 	proc A forks to create Z
> 		Z forks to exec
> 		Z waits for exec'ed child
> 		Z notifies B and C however you like
>

That's what I did.:) I was just curious if there is a better way.

Thanks,
	Lucho


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

* Re: [9fans] fork/exec and waitpid from another proc
@ 2002-05-10 11:32 Russ Cox
  2002-05-10 14:20 ` Latchesar Ionkov
  0 siblings, 1 reply; 5+ messages in thread
From: Russ Cox @ 2002-05-10 11:32 UTC (permalink / raw)
  To: 9fans

> I have a threaded process. Proc A executes new program X using fork and exec.
> After the creation proc A continues its work. Procs B and C want to know
> when/if the process X finished. As process X is not child process of B and C
> and they can't wait(2) on it. Proc A has something else to do and doesn't
> care what B and C want.

as you have described it, no.

but you could introduce yet another proc:

	proc A forks to create Z
		Z forks to exec
		Z waits for exec'ed child
		Z notifies B and C however you like

russ


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

* [9fans] fork/exec and waitpid from another proc
@ 2002-05-10 11:17 Latchesar Ionkov
  0 siblings, 0 replies; 5+ messages in thread
From: Latchesar Ionkov @ 2002-05-10 11:17 UTC (permalink / raw)
  To: 9fans

Hi,

I have to implement something and I am not sure I know the best way to do it.

I have a threaded process. Proc A executes new program X using fork and exec.
After the creation proc A continues its work. Procs B and C want to know
when/if the process X finished. As process X is not child process of B and C
and they can't wait(2) on it. Proc A has something else to do and doesn't
care what B and C want.

Is there easy solution for this? In Unix I can use SIGCHLD for proc A to do
something.

Thanks,

	Lucho


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

end of thread, other threads:[~2002-05-10 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-10 15:27 [9fans] fork/exec and waitpid from another proc rob pike, esq.
2002-05-10 15:54 ` Latchesar Ionkov
  -- strict thread matches above, loose matches on Subject: below --
2002-05-10 11:32 Russ Cox
2002-05-10 14:20 ` Latchesar Ionkov
2002-05-10 11:17 Latchesar Ionkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).