Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of signal handling #322

Closed
13k opened this issue Jun 12, 2021 · 0 comments · Fixed by #377
Closed

Lack of signal handling #322

13k opened this issue Jun 12, 2021 · 0 comments · Fixed by #377

Comments

@13k
Copy link

13k commented Jun 12, 2021

  • Ruby version: Not applicable
  • Rubyfmt git sha: 5ebcd9f

Input file

Any input, immediately followed by any signal (tested SIGINT or SIGTERM).

Or reading from tty's stdin, typing anything, Ctrl-C, then Ctrl-D.

Rubyfmt's output

Not applicable.

This breaks because

Reading from tty, segfaults (on Linux):

> target/release/rubyfmt-main 
hello world
^CSegmentation fault (core dumped)

Sending a signal to the process, main thread panics:

> { target/release/rubyfmt-main < librubyfmt/ruby_checkout/ruby-2.6.6/lib/irb.rb & }; pkill -INT rubyfmt-main
[1] 1307711
thread 'main' panicked at 'bad init status: Interrupt', src/main.rs:119:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[1]+  Exit 101                target/release/rubyfmt-main < librubyfmt/ruby_checkout/ruby-2.6.6/lib/irb.rb

I'm not sure about what to do when handling signals during processing with non-interactive inputs (process stdin or files), specially if it's running in "in place mode" (probably write results when it's guaranteed formatting is finished); but when reading from tty, I'd expect to be able to cancel and exit the process with SIGINT, like (most) command-line tools do.

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 a pull request may close this issue.

1 participant