1

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.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Tim
  • 98,580
  • 191
  • 570
  • 977
  • Have you tried using `screen` or `tmux`? – muru Dec 03 '14 at 13:23
  • no. I haven't. . – Tim Dec 03 '14 at 13:24
  • I think this would already be addressed somewhere on U&L or on [ubuntu.se], but here's a quick guide: http://unix.stackexchange.com/a/108984/70524, you can simplify the process by using `byobu`. – muru Dec 03 '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 `disown`ing the process you change its parent to init, after that you cannot "reattach" the process to other parent. – jimmij Dec 03 '14 at 13:27
  • And also `reptyer` (which looks like it needs `screen` or `tmux`, not sure though): https://github.com/nelhage/reptyr – muru Dec 03 '14 at 13:29
  • It's not just about which is the parent process, the background process also has its standard input, output and error output connected to the current terminal. That's why you need something like the already mentioned `screen` or `tmux` to manage the "virtual" terminal. – wurtel Dec 03 '14 at 15:43

1 Answers1

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.

muru
  • 69,900
  • 13
  • 192
  • 292
Alex Grin
  • 286
  • 2
  • 5
  • 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 03 '14 at 23:35