evilmartians/lefthook

Option to redirect standard input to `/dev/null`

sanmai-NL opened this issue · 5 comments

⚡ Summary

Similar to a subset of the options in https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Logging%20and%20Standard%20Input/Output

Value

There are situations in complex CI environments where Lefthook will stall, when not using use_stdin: true. How can a user make sure that commands can never use stdin without causing crashes (by closing the file descriptor)? By redirecting stdin to /dev/null or a similar concept in Windows. Currently, the user has to configure use_stdin: true with every command that could possibly stall Lefthook, even if they don't want those commands to use standard input at all.

Behavior and configuration changes

Nothing, although that options remains open in my view. But this suggestion is to extend behavior by offering a default false redirection option.

Hey @sanmai-NL, I am currently solving an issue related to STDIN right now :)

In this PR I explicitly pass null reader (a reader that returns EOF on every read) to commands that don't explicitly specify use_stdin: true or interactive: true.

I think this is the behavior that prevents commands from being stuck on waiting for input. Do you agree?

I think that should work, but see my reference. Managing which process controls the tty could also solve this.

@mrexox Was this also resolved with #732?

This now works by default (not via an option). All commands get just EOF when they try to read from STDIN if they don't specify use_stdin: true or interactive: true.

I have concerns of whether a global option is useful. Do you think we should close the feature request or specify it?

Can be closed IMO.