tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Reparenting processes?



On Mon, Dec 07, 2020 at 08:54:33PM -0500, Mouse wrote:
> I've been thinking about building a way to move a job between shells,
> in particular between one window, ssh session, whatever, and another.

Yes, I've somehow missed the VMS virtual terminals, that can detach
their job from the real terminal and be reattached by a login process,
instead of creating a new job.

(screen and tmux have lessened this desire to a high degree.)
 
> Obviously, this will involve much hackery of existing facilities.  For
> example, it involves switching controlling terminals.  I expect I can
> manage most of it without too much trouble - though that's said without
> having actually tried it.
> 
> But the real bugaboo in my mind is reparenting processes.

Why do you need this? I think that (get|set)pg(rp|id)() and
tcgetpgrp()/tcsetpgrp() should be enough to do job manipulation.
 
> The other is: is there any security property that such a facility would
> break badly? 

One that I can think of: if you are able to change your parent to one
of your indirect children, functions traversing the process tree would
either not find you (and your decendants) or run in an infinite loop.

(Needs traversing the new parent's parent chain up, make sure the moving
process is not there, (and maybe for good measure, that we arrive at 1), 
all with a lock held.)

The other interesting question: what happens to a process that was
seperated by its child but still knows the id and plans some
operation on it?

	-is


Home | Main Index | Thread Index | Old Index