nelhage/reptyr — dự án mã nguồn mở — đang có 6.4k sao GitHub. Reparent a running program to a new terminal
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
reptyr is a utility for taking an existing running program and
attaching it to a new terminal. Started a long-running process over
ssh, but have to leave and don't want to interrupt it? Just start a
screen, use reptyr to grab it, and then kill the ssh session and head
on home.
USAGE
reptyr PID
"reptyr PID" will grab the process with id PID and attach it to your
current terminal.
After attaching, the process will take input from and write output to
the new terminal, including ^C and ^Z. (Unfortunately, if you
background it, you will still have to run "bg" or "fg" in the old
terminal. This is likely impossible to fix in a reasonable way without
patching your shell.)
Typical usage pattern
Start a long running process, e.g. top
Background the process with CTRL-Z
Resume the process in the background: bg
Display your running background jobs with jobs -l, this should look like this:
[1]+ 4711 Stopped (signal) top
(The -l in jobs -l makes sure you'll get the PID)
Disown the jobs from the current parent with disown top. After that, jobs will not show the job any more, but ps -a will.
Start your terminal multiplexer of choice, e.g. tmux
Reattach to the backgrounded process: reptyr 4711
Detach your terminal multiplexer (e.g. CTRL-A D) and close ssh
Reconnect ssh, attach to your multiplexer (e.g. tmux attach), rejoice!
"But wait, isn't this just screenify?"
There's a shell script called "screenify" that's been going around the
internet for nigh on 10 years now that uses gdb to (supposedly)
accomplish the same thing. The difference is that reptyr works much,
much, better.
If you attach a "less" using screenify, it will still take input from
the old terminal. If you attach an ncurses program using screenify,
and resize the window, your program won't notice. If you attach a
process with screenify, ^C in the new terminal won't work.
reptyr fixes all of these problems, and is the only such tool I know
of that does so. See below for some more details on how it
accomplishes this.
PORTABILITY
reptyr supports Linux and FreeBSD. Not all functionality is currently
available on FreeBSD. (Notably, FreeBSD doesn't support reptyr -T at
this time.
reptyr uses ptrace to attach to the target and control it at the
syscall level, so it is highly dependent on details of the syscall
API, available syscalls, and terminal ioctl()s. A port to other
operating systems may be technically feasible, but requires
significant low-level knowledge of the relevant platform, and may
entail significant refactors.
reptyr works on i386, x86_64, and ARM. Ports to other architectures should be
straightforward, and should in most cases be as simple as adding an arch/ARCH.h
file and adding a clause to the ifdef ladder in ptrace.c.
ptrace_scope on Ubuntu Maverick and up
reptyr depends on the ptrace system call to attach to the remote program. On
Ubuntu Maverick and higher, this ability is disabled by default for security
reasons. You can enable it temporarily by doing
# echo 0 > /proc/sys/kernel/yama/ptrace_scope
as root, or permanently by editing the file /etc/sysctl.d/10-ptrace.conf, which
also contains more information about exactly what this setting accomplishes.
reptyr -l
As a bonus feature, if you run "reptyr -l", reptyr will create a new
pseudo-terminal pair with nothing attached to the slave end, and print
its name out.
If you are debugging a program in gdb, you can pass that name to "set
inferior-pty". Because there is no existing program listening to that
tty, this will work much better than passing an existing shell's
terminal.
How does it work?
The main thing that reptyr does that no one else does is that it
actually changes the controlling terminal of the process you are
attaching. I wrote a
blog post
explaining just what the shenanigans involved are.
PRONUNCIATION
I pronounce it like "repeater", but since that's easily ambiguous,
"re-P-T-Y-er" is also acceptable.
CREDITS
reptyr was written by Nelson Elhage [email protected]. Contact him
with any questions or bug reports.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/nelhage/reptyr là nguồn chính thức.
nelhage/reptyr có bao nhiêu sao?
nelhage/reptyr có 6.4k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/nelhage/reptyr. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
nelhage/reptyr có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho nelhage/reptyr. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
nelhage/reptyr có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho nelhage/reptyr. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
nelhage/reptyr còn đang phát triển không?
Commit gần nhất trên nelhage/reptyr là 1 tháng trước (theo timestamp GitHub). Repo có 230 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
nelhage/reptyr dùng license gì?
nelhage/reptyr phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
nelhage/reptyr viết bằng ngôn ngữ gì?
nelhage/reptyr chủ yếu viết bằng C. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc reptyr có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về reptyr.