nelhage / reptyr

Reparent a running program to a new terminal
MIT License
5.77k stars 216 forks source link

When running as daemon, CPU usage is constantly at 100% #103

Open cmpitg opened 5 years ago

cmpitg commented 5 years ago

One of my use case with reptyr is with -L, to start an Emacs server process with an allocated PTY. Running reptyr -L emacs --fg-daemon=<server-name> works as expected. Unfortunately, when integrating the command with Runit[^1], the CPU usage caused by reptyr was constantly at 100%:

#!/usr/bin/env sh

exec 2>&1
exec reptyr -L emacs --fg-daemon=<server-name>

At first I thought was Emacs being mischievous. However, this happened even with simple shell scripts such as the following:

#!/usr/bin/env bash

while true; do
    echo $(date -R)
    sleep 1
done

The CPU usage came back to normal when running without reptyr -L. Any idea what might be the cause?

[^1] http://smarden.org/runit/