>> 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.
That must have come in after I stopped using VMS (mid-'80s); I'm pretty sure the VMS I used didn't have it. > (screen and tmux have lessened this desire to a high degree.) Not surprising. :-) >> 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. Reparenting is semi-necessary in order for wait*() to work right. Also, if you can move a stopped setuid job, the carveout for sending SIGCONT to any descendant needs to apply. And the job's control tty needs to change so it can interact with the tty expected by the new shell. It probably should change session, too. >> 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. Certainly; I was expecting to forbid parenting loops. (This is one of the respects in which ptrace()'s reparenting is only partial; debuggers can attach to their process-tree ancestors just fine.) > 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? For my use cases, that is a non-issue; I expect this to happen only with the cooperation and collaboration of both parents. The old parent can operate on the former child after the move only to the extent that it could operate on a similar child forked by the new parent. /~\ The ASCII Mouse \ / Ribbon Campaign X Against HTML mo...@rodents-montreal.org / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B