1

This question already has an answer here:

I have a background job, say jobid 1, in a tab of gnome terminal. Can I move it to a another tab of genome terminal?

I understand that the shell process in the first gnome terminal tab is the parent of the background process. So am I to change the parent/owner of the background process?

I guess that it is the same regardless of a process to be moved is running background or foreground?

Do I need some identifiers of the tabs of gnome terminal, tty things?

I don't really know how to do the above. Just some guessing.

marked as duplicate by Gilles, slm Dec 4 '14 at 1:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Have you tried using screen or tmux? – muru Dec 3 '14 at 13:23
  • no. I haven't. . – Tim Dec 3 '14 at 13:24
  • I think this would already be addressed somewhere on U&L or on Ask Ubuntu, but here's a quick guide: unix.stackexchange.com/a/108984/70524, you can simplify the process by using byobu. – muru Dec 3 '14 at 13:26
  • 1
    You cannot change parent of the process. The only difference is init process, which is the parent of every other process, and by disowning the process you change its parent to init, after that you cannot "reattach" the process to other parent. – jimmij Dec 3 '14 at 13:27
  • And also reptyer (which looks like it needs screen or tmux, not sure though): github.com/nelhage/reptyr – muru Dec 3 '14 at 13:29
3

You can start the process in screen, type screen (it will start new screen session), run any command just like in your regular shell, detach screen (by pressing Ctrla, then d) and attach to the screen from any other terminal tab by typing screen -r.

In this case the process's parent is screen, which is detachable / attachable from any terminal session, including remote SSH sessions.

  • Thanks. (1) WIthout screen or tmux or likes, is it unlikely to change teh terminal session for a running job? (2) I haven't formed the habit of always running any program in screen or tmux yet. Is it recommended to do so, or just for some special jobs? (3) I heard that a job not running in screen can always be put inside a screen session, right? – Tim Dec 3 '14 at 23:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.