[tor-relays] Programmatically determine if a relay is hibernating

Hello.

What is the authoritative way to determine if a relay is hibernating? I
would have thought that using the control socket would be best, but Tor
seems to unlink it when it enters hibernation, so Stem does not work.

There's a possible heuristic by checking if /run/tor/tor.pid exists when
/run/tor/control does not, but that's fragile because it assumes that
the control socket is even enabled. Parsing the logs is doable, but also
quite fragile. And I could certainly parse /var/lib/tor/state, but its
format is surely subject to change at any time.

How do I correctly determine whether a Tor process is in hibernation?

Regards,
forest

···

_______________________________________________
tor-relays mailing list -- tor-relays@lists.torproject.org
To unsubscribe send an email to tor-relays-leave@lists.torproject.org

Yes, you should do it by querying the control interface. Here's what my
relay answers when it's hibernating:

$ telnet localhost 9150
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
authenticate
250 OK
getinfo accounting/hibernating
250-accounting/hibernating=hard
250 OK

I just tested by configuring a controlsocket and it seems to survive
hibernation too. If yours doesn't, please file a bug -- but make sure
that it isn't a Stem bug first.

--Roger

···

On Sun, Feb 15, 2026 at 12:22:50AM -0000, forest-relay-contact--- via tor-relays wrote:

What is the authoritative way to determine if a relay is hibernating? I
would have thought that using the control socket would be best, but Tor
seems to unlink it when it enters hibernation, so Stem does not work.

_______________________________________________
tor-relays mailing list -- tor-relays@lists.torproject.org
To unsubscribe send an email to tor-relays-leave@lists.torproject.org