2

Is it possible to have a already started program move to screen/tmux? I'd like to have something like the following:

program;
^Z
screen;
fg;

I know the above won't work, but is there a way to accomplish this?

Oliver Salzburg
  • 86,445
  • 63
  • 260
  • 306
knittl
  • 3,962
  • 2
  • 18
  • 18
  • It is *not a duplicate* of [that question](http://superuser.com/questions/116743/send-command-to-an-already-running-screen-session), as in this one, the user is already running the `program` and wants to suspend it (`^Z`), *then* move to a screen. – Daniel Beck Dec 13 '11 at 08:16
  • Yes exactly. The program is already running, but then I decide it's better to have it in a screen (so I can leave my PC). I don't care if it creates a new screen session or is added to an existing one … – knittl Dec 13 '11 at 08:20
  • If it's a non-interactive program, couldn't you just use `disown`? – Daniel Beck Dec 13 '11 at 08:21
  • This is a problem of moving a child process under another parent. – karatedog Dec 13 '11 at 09:04

1 Answers1

2

The problem is under no circumstances simple to solve, but have a look at reptyr. It can sometimes help you, especially if you don't care about noise printed in the original terminal & c. You'll might have to compile it yourself, although some distros, Gentoo for instance, package it.

Eroen
  • 6,383
  • 1
  • 17
  • 25