How can I move my current session from GNU screen to tmux?

0

My IRC client, irssi, is currently active inside a GNU screen session.
In hindsight, I wish that I'd have used tmux instead of GNU screen.
How can I migrate the active process (or session) from GNU screen to tmux?

voices

Posted 2016-03-08T07:03:31.897

Reputation: 2 053

Adding as a comment since this migrates to tmux, but doesn't actually migrate from screen as asked. [1] * Press Ctrl-A, then d (detach screen) [2] Run tmux [3] Run: screen -R -x [4] Enjoy tmux. Don't press Ctrl-A. Ignore screen. – TOOGAM – 2016-03-08T15:59:57.693

Answers

1

Use reptyr.

This other answer of mine provides useful details. It is about migrating an outside process into screen/tmux, but I have just tested on my Debian 9 and successfully migrated htop from screen to tmux.

After finding the PID of htop, I invoked reptyr PID from a shell inside tmux. I then went back to screen and terminated it totally; this included exiting the shell that had started htop. htop did survive attached to a tty provided by tmux. I believe your irssi will survive as well.

exec reptyr PID or tmux new-window 'reptyr PID' would also work, although there would be no shell between the tmux server and reptyr. In case of a simple reptyr PID invoked in an interactive shell, the shell keeps running and you will get back to it after the captured process terminates eventually.

Kamil Maciorowski

Posted 2016-03-08T07:03:31.897

Reputation: 38 429

1@Attie ptrace_scope=0 is not the only option. I expanded the linked answer. – Kamil Maciorowski – 2019-10-17T12:00:39.063

0

Migrating an active session from screen to tmux is unfortunately not possible today as the functionality to do so has not been developed. They are completely different applications and don't support managing each other's sessions - that may change in future, but it's not possible as of April 2016.

What I'd suggest as a workaround is attaching to your existing irssi screen session within a tmux window. In other words, do a screen -r from within one of your tmux windows. You may have some conflicts if their keybindings clash (for example if you've remapped your tmux hotkey to be Ctrl-A, the screen default), but you can at least just use one application and not two.

mjturner

Posted 2016-03-08T07:03:31.897

Reputation: 296

1Not possible, or not supported? What technical limitation prevents the possibility of making the required changes in RAM? – TOOGAM – 2016-03-08T15:56:05.020

Well, yes you're right. There's nothing making it impossible - tmux and/or screen could add support for managing the other's sessions. I'll amend my answer to make it a bit clear - it's not possible today as the support isn't there. But that may, of course, change at some point... – mjturner – 2016-03-30T18:46:41.110

Your attempt at making "not possible" more clear has been successful, yet the current phrasing still feels wrong. You may want to look up the definition of "possible", and contrast that to some other words or phrases, such as "supported option", "a convenient process/procedure", "currently implemented feature", "available usable functionality", etc. These are open source programs, and statements like "not possible" may dissuade novice coders from even considering the task of adding such functionality. – TOOGAM – 2016-03-30T20:48:08.480

1shrug I think "possible today" makes it fairly clear. Feel free to rewrite my answer if you're still unhappy... – mjturner – 2016-03-30T21:03:07.160