Transferring a parent process and its childs

Suppose I have a konsole running with a process building a port package and plasma session crashed (again 😣) and now I want to transfer the process and its sub process to a tty, what's the proper way of doing it? and is reptyr the right tool?
 
If the supposition is the current reality, it's too late for using tmux. sysutils/reptyr is indeed worth a try.
yes the supposition is true, but the way I understood it, reptyr can manage to transfer only one process, not the tree of that process. I did run a make install which has many child process, it still running in the konsole, but the plasma session isn't working.
 
systeutils/reptyr with tmux is probably what you want. Start whatever you're doing in a tmux session make a note of its PID. As I write this, I was thinking that that was what I used to do, but I realize I'm remembering incorrectly. Still, it sounds like it might work. <shrug> Sorry, it really did seem a good idea when I started typing--I'm leaving the thought here to see what other, smarter people will say.
 
Maybe the child processes of the make program are in the file descriptor of that programs?

reptyr works by attaching to the target program using
ptrace(2), redirecting relevant file descriptors,
 
-T

Use an alternate mode of attaching, "TTY-stealing". In
this mode, reptyr will not ptrace(2) the target
process, but will attempt to discover the terminal
emulator for that process' pty, and steal the master
end of the pty. This mode is more reliable and flexible
in many circumstances (for instance, it can attach all
processes on a tty, rather than just a single process).
However, as a downside, children of sshd(8) cannot be
attached via -T unless reptyr is run as root. See for
more information about tty-stealing.
it migth work but this not a quote from freebsd manpages ,but rather termux. I'll have to check if the option is in freebsd too.

[edit]

Yes same its the same manpages.
 
It didn't work (I mean for me, my need, otherwise it worked as expected) reptyr [PID] it waited for child process to stop, it would have waited the build to be done. This is not what I was looking for. the only option that would have worked doesn't on freebsd.

I did [CTR-C] to terminate it and it kill the all thing because it was the parent process I was messing with.

I'm making install again in tty this time

I'll leave this thread open in case someone have anything to add and maybe a solution.
 
I just found, several months later, that I have similar issues. I used to use reptyr all the time, with nothing but the PID, e.g.,
Code:
 reptyr 12345
and it was fine--maybe this was around FreeBSD-13? Anyway on FreeBSD-15-RELEASE, it no longer works for me, if I use no options, it just says
Code:
unable to attach to pid 12345: Cannot allocate memory
. So after a bit of websearching I tried with reptyr -T and like Charlie Brown I got bad address.

I never used it that often, so I'm not sure when this began, I just remember that I used to be able to use it a year or so ago, maybe longer.
 

THIS is what you want.

see
$ man tmux

You can <detach> the running tmux session and then reattach to the running tmux session again from the same (or a different) tty. I do this all the time for basically the same issue you are trying to solve. The result is... it's like you never left your TTY. You can also have/create/use/switch between as many TTY sessions as you like running and they will ALL be there and in the "up-to-date" state when you <reattach> your tmux(1) or screen(1) session from the tty command line.


As loveydovey indicates: screen(1) is a good choice as well - screen(1) a much older program than tmux(1) but works great! I actually use both and I might be partial to screen(1) because I have used screen(1) for many many years on *BSD's, Unix and Linux.

In screen(1):
To detach all your running screen session use <Ctrl>a d (CTRL+A plus the 'd' key)
To run screen and reattach to all of your tty sessions again use: $ screen -r

See
$ man screen

Having "just" tried both programs -- I think screen(1) looks better on FreeBSD hosts... but to each their own !

NOTE: To read the man(1) page for screen(1) you (will also) need to install the pkg groff:
# pkg install groff
 
Back
Top