HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
nelhage
reptyr
C2011–2025
nelhage / reptyr

reptyr

Reparent a running program to a new terminal

18Distinct people
20Mentions
0Explicit recommenders
6.4KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Reparent a running program to a new terminal

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year20 dated mentions

Observed mentions: 2011-01-22 05:11:19 UTC to 2025-12-11 13:46:48 UTC.

012342011-01-01 00:00:00 UTC to 2012-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20112012-01-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 4 mentions; 2 submissions, 2 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20112011-01-01 00:00:00 UTC2012-01-01 00:00:00 UTC312
20122012-01-01 00:00:00 UTC2013-01-01 00:00:00 UTC000
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC000
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC422
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC202
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC000
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC110
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC101
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC110
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC110
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC110
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC303
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

What Hacker News says

20 sources
We considered to use sth like this to cache some Python program state to speed up the startup time, as the startup time was quite long for some of our scripts (due to slow NFS, but also importing lots of libs, like PyTorch or TensorFlow). We wanted to store the program state right after importing the modules and loading some static stuff, before executing the actual script or doing other dynamic stuff. So updating the script is still possible while keeping the same state. Back then, CRIU turned out to not be an option for us. E.g. one of the problems was that it was not possible to be used as non-root (https://github.com/checkpoint-restore/criu/pull/1930). I see that this PR was merged now, so maybe this works now? Not sure if there are other issues. We also considered DMTCP (https://github.com/dmtcp/dmtcp/) as another alternative to CRIU
Read the rest
, but that had other issues (I don't remember). The solution I ended up was to implement a fork server. Some server proc starts initially and only preloads the modules and maybe other things, and then waits. Once I want to execute some script, I can fork from the server and use this forked process right away. I used similar logic as in reptyr (https://github.com/nelhage/reptyr) to redirect the PTY. This worked quite well. https://github.com/albertz/python-preloaded
In CRIU, a project to implement checkpoint/restore functionality for Linux
> I am glad vim has the option to place the swap files where you want them, and make them unique (by setting 'directory' to end with "//"). i am glad as well. not every program supports --exclude/--except. i used to keep swapfiles in a single global directory, but i've instead started to try to stash my swapfiles "near" the code: alias vi='vim --cmd "$(x="$(git rev-parse --show-toplevel 2>/dev/null)"; [ "x$x" != x/ ] && mkdir -p "$x/.git/_vim" 2>/dev/null && echo "set dir=$x/.git/_vim//")"' this seems to have some advantages: for example, i can do a find / -name '*.swp' to figure out what i was working on when most of the files are readme.md (i should note, real ed doesn't create ed.hup files; that's a weird gnuism) > For vim and ed and every other console program, I would run them inside screen(1) to avoid losing work due to networ
Read the rest
k troubles, and network disconnects is usually where I get my SIGHUP. i don't like screen very much, even though i do continue to use it (owing more to its ubiquity and utility); it's full of all kinds of questionable ui decisions, and so many features i use so infrequently i need to constantly be re-reading the manual. i think if you have learned it and liked it okay, but all i ever want is terminal mobility, and i get a much nicer experience out of two tools: - mosh: https://mosh.org/ - reptyr: https://github.com/nelhage/reptyr using mosh means i don't get SIGHUP, and if i lose my local display, i can open another mosh, reptr my old session (it's still there!) and keep on hacking.
In GNU ed ate my homework
There's no function, given the PID of a target process, to inject code directly. In order to load code from a library, you need to A) map the library into memory B) handle relocations (i.e., connect up that library's references to functions in already-loaded libraries like libc) C) start executing it. Step A can be done from a process itself with mmap, but there isn't a function to map memory into another process. Step B is just some modifications to values in memory. Step C involves somehow changing the instruction pointer. All of these are easy to do if you're running code as the process itself - in particular, if you can get control of the instruction pointer, you can avoid doing steps A and B manually by just instructing the program to use the existing libc dlopen() function, which mmaps a library and handles relocations. So we need t
Read the rest
o be able to change the instruction pointer of the process and coax it into calling dlopen(). The functionality available to you is: - You can use ptrace to stop the process, read and write the saved registers, read and write its memory, resume the process, or resume the process until the next instruction (single step) or next syscall. It's the API used by debuggers. If you run `print dlopen("file.so")` from GDB, this is exactly what GDB will do: it'll use ptrace to make up a stack frame to call dlopen with the arguments you specify and then hit a breakpoint, and GDB will print the result. Another good example of using this to inject code for non-malicious purposes is https://github.com/nelhage/reptyr , which lets you tell another process to switch terminals (e.g., move it into a screen/tmux session). - You can use /proc/$pid/mem or the process_vm_writev syscall to modify the stack but not the instruction pointer, because the stack is in memory. That puts you effectively in the same position as an exploit writer: you have to create a stack frame that returns to custom code somehow, or uses return-oriented programming to call the function you want to call. Then when the program returns from its current stack frame, it'll call your shellcode or ROP gadget. - You can use /proc/$pid/mem or the process_vm_writev syscall to modify the code at the instruction pointer, even though you can't modify the instruction pointer itself. That's what this program does - it backs up a segment of instructions about to be executed, overwrites it with shellcode, and restores the instructions once the shellcode is done. ptrace, /proc/$pid/mem, and process_vm_readv/writev have permission checks. On most systems, you have to be running as the same user as the program you're trying to mess with. On systems including the "Yama" Linux security module - notably including Ubuntu - you also have to be an ancestor process of the process you're trying to attach to, which is a security measure intended to make it harder for malware to steal secrets out of other programs you're running, without preventing debuggers etc. from working. See https://www.kernel.org/doc/Documentation/security/Yama.txt for details. (Again, this is the same interface as a debugger uses. If you're not prevented from debugging your own programs, yes, you can inject malicious code into them without limitation - and it's generally easier to use a debugger than to write your own custom injector to do it.)
In Show HN: dlinject.py – Inject a .so into a running Linux process, without ptrace

Showing the 15 most recent of 20 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.