Skip to content

Conversation

ciderale
Copy link
Contributor

@ciderale ciderale commented Aug 1, 2025

This PR ensures that the backgrounded reboot command is fully detached, preventing SSH from occasionally hanging after the command is sent. By redirecting both stdout and stderr, the ssh session can close cleanly without waiting on open channels. This project is really cool and I hope to contribute a small improvement.

@Enzime Enzime added this pull request to the merge queue Aug 2, 2025
@Enzime
Copy link
Member

Enzime commented Aug 2, 2025

Out of curiosity, have you observed it hanging much and is it when something writes to stderr?

Merged via the queue into nix-community:main with commit bc653a8 Aug 2, 2025
4 checks passed
@ciderale
Copy link
Contributor Author

ciderale commented Aug 2, 2025

I run it from a script that boots a vm with vfkit and then starts the nixes-anywhere installation, nothing really special.
I'd say it was hanging in about 50% of the cases. Regarding outputs, the only thing I observed is a remark about not allocating pseudo-terminal (see below), which likely is on stderr, but I suppose from ssh locally, not the executed script.

What I observed is after the fix is, that the ssh session exists immediately. Before, it seems to wait for some seconds (the sleep 6 I guess) until it exits. My interpretation is that before the fix, the reboot and ssh exit are kind of simultaneous causing a race condition -- which the sleep 6 tries to avoid.

Installation finished. No error reported.
installation finished!
### Rebooting ###
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added '[localhost]:3223' (ED25519) to the list of known hosts.
    (script is hanging here)

@Enzime
Copy link
Member

Enzime commented Aug 3, 2025

Interesting, I wonder if sleep 6 is no longer necessary then @Mic92

@Mic92
Copy link
Member

Mic92 commented Aug 3, 2025

Interesting, I wonder if sleep 6 is no longer necessary then @Mic92

The 6s were there so that we get a clean exit status and the kexec doesn't break the connection before the command finishes. I picked the rather high timeout in case we have a slow connection i.e. tor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants