supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* orphan processes
@ 2007-06-06  0:17 Adam Megacz
  2007-06-06  0:43 ` Paul Jarc
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Megacz @ 2007-06-06  0:17 UTC (permalink / raw)
  To: supervision


I've got some media-encoding scripts running under runit that seem to
cause orphan processes quite a lot -- in some chain of script invocations,

  runsv
    |
    +-- script1.sh
       |
       +-- script2.sh
          |
          +-- script3.sh

Somehow script2.sh dies, script3 gets reparented to init (I'm running
runit-as-a-child-of-svrinit), and then eventually when script1
finishes and the whole thing restarts, I wind up with two copies of
script3.sh.

Anyways, this got me thinking: is there any way in UNIX for the leader
of a process/session group to tell the system that orphan processes in
that group should be reparented to the leader rather than "pid 1"?  If
there were some way, I could add an option to runsv to tell it to
immediately kill any process which unexpectedly becomes its child (ie
orphans).

  - a

-- 
PGP/GPG: 5C9F F366 C9CF 2145 E770  B1B8 EFB1 462D A146 C380



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

* Re: orphan processes
  2007-06-06  0:17 orphan processes Adam Megacz
@ 2007-06-06  0:43 ` Paul Jarc
  2007-06-06  1:09   ` Charlie Brady
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Jarc @ 2007-06-06  0:43 UTC (permalink / raw)
  To: Adam Megacz; +Cc: supervision

Adam Megacz <adam@megacz.com> wrote:
> Somehow script2.sh dies, script3 gets reparented to init (I'm running
> runit-as-a-child-of-svrinit), and then eventually when script1
> finishes and the whole thing restarts, I wind up with two copies of
> script3.sh.

If script1 starts by putting itself in a new process group before
spawning any children, then at the end it can send SIGTERM to its
process group to kill all related processes.

> Anyways, this got me thinking: is there any way in UNIX for the leader
> of a process/session group to tell the system that orphan processes in
> that group should be reparented to the leader rather than "pid 1"?

I don't think so.


paul


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

* Re: orphan processes
  2007-06-06  0:43 ` Paul Jarc
@ 2007-06-06  1:09   ` Charlie Brady
  0 siblings, 0 replies; 3+ messages in thread
From: Charlie Brady @ 2007-06-06  1:09 UTC (permalink / raw)
  To: Adam Megacz, Paul Jarc; +Cc: supervision


On Tue, 5 Jun 2007, Paul Jarc wrote:

>> Anyways, this got me thinking: is there any way in UNIX for the leader
>> of a process/session group to tell the system that orphan processes in
>> that group should be reparented to the leader rather than "pid 1"?
>
> I don't think so.

Not as such. But do some research on linux "containers" and "pid 
namespace". It's possible to have multiple sets of pids, including 
multiple pid 1s. Each pid 1 will collect orphan processes within its own 
pid namespace.


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

end of thread, other threads:[~2007-06-06  1:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-06  0:17 orphan processes Adam Megacz
2007-06-06  0:43 ` Paul Jarc
2007-06-06  1:09   ` Charlie Brady

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).