I have a few terminals open. I'd like to send the processes in those terminals to a tmux session rather than saving, closing, restarting under tmux, and then getting the process back to the state it's currently in.

How do I attach a running non-tmux process to a tmux session?

  • 2
    Unfortunately, you can't. – jjlin Feb 19 '14 at 2:57

reptyr should do that job. See github

Find out the process id of the job you want to transfer. I usually do this by typing

ps -p | grep programname

then go to the tmux session, window, pane, ... and insert:

reptyr PID

where PID is the process id you just found out.

This workflow should be scriptable.

If some message appears, that tells that it does not work:

Unable to attach to pid 4625: Operation not permitted
The kernel denied permission while attaching

Type in as root for allowing the above:

echo 0 > /proc/sys/kernel/yama/ptrace_scope
  • Thanks. Tried this but did not succeed. – isomorphismes Feb 23 '14 at 5:32
  • 1
    @isomorphismes: I tried it too , now, worked like a charm. But, I had to execute echo 0 > /proc/sys/kernel/yama/ptrace_scope beforehand as root, since this operation was not allowed by default. – spiehr Feb 23 '14 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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