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

Hitting CTRL+C while inside nanoc shell always exits abruptly #1309

Closed
gpakosz opened this Issue Jan 31, 2018 · 7 comments

Comments

Projects
None yet
2 participants
@gpakosz
Member

gpakosz commented Jan 31, 2018

Within nanoc shell, hitting CTRL+C quits abruptly with "stdout closed".

You need to $ reset your terminal emulator to move on.

Steps to reproduce

  1. bundle exec nanoc shell
  2. hit CTRL+C
  3. Nanoc shell exists leaving terminal seemingly unresponsive: you have to $ reset before being able to see what you're typing again

Another manifestation of the bug

  1. bundle exec nanoc shell
  2. start typing some Ruby
  3. realize you messed up and try to hit CTRL+C to cancel your typing
  4. Nanoc shell exits leaving terminal seemingly unresponsive, instead of cancelling the typing

Expected behavior

Nanoc shell cancels current typing instead of always exiting. Nanoc shell only exits when the REPL input is empty, just like irb.

In any case when Nanoc shell exits, one shouldn't have to $ reset the terminal emulator.

@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Jan 31, 2018

Member

Can you show me the output of bundle exec nanoc --version?

Member

ddfreyne commented Jan 31, 2018

Can you show me the output of bundle exec nanoc --version?

@gpakosz

This comment has been minimized.

Show comment
Hide comment
@gpakosz

gpakosz Jan 31, 2018

Member

Oops sorry, it's nanoc 4.8.16

$ bundle exec nanoc --version
Nanoc 4.8.16 © 2007-2017 Denis Defreyne.
Running ruby 2.4.3 (2017-12-14) on x86_64-darwin16 with RubyGems 2.6.14.
Member

gpakosz commented Jan 31, 2018

Oops sorry, it's nanoc 4.8.16

$ bundle exec nanoc --version
Nanoc 4.8.16 © 2007-2017 Denis Defreyne.
Running ruby 2.4.3 (2017-12-14) on x86_64-darwin16 with RubyGems 2.6.14.
@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Jan 31, 2018

Member

I can’t reproduce this problem, unfortunately!

The Nanoc, Ruby and RubyGems are recent enough, too.

It appears other people have had similar issues with Pry: see e.g. pry/pry#1275, which is a Pry issue that has been open for quite a while.

Member

ddfreyne commented Jan 31, 2018

I can’t reproduce this problem, unfortunately!

The Nanoc, Ruby and RubyGems are recent enough, too.

It appears other people have had similar issues with Pry: see e.g. pry/pry#1275, which is a Pry issue that has been open for quite a while.

@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Feb 7, 2018

Member

@gpakosz Is this a problem for you with pure pry as well, or just nanoc shell?

Member

ddfreyne commented Feb 7, 2018

@gpakosz Is this a problem for you with pure pry as well, or just nanoc shell?

@gpakosz

This comment has been minimized.

Show comment
Hide comment
@gpakosz

gpakosz Feb 7, 2018

Member

When I launch pry, hitting CTRL+C doesn't exit pry:

image

Member

gpakosz commented Feb 7, 2018

When I launch pry, hitting CTRL+C doesn't exit pry:

image

@ddfreyne

This comment has been minimized.

Show comment
Hide comment
@ddfreyne

ddfreyne Feb 17, 2018

Member

@gpakosz Does the problem persist when you do the following?

  1. bundle exec nanoc shell
  2. Signal.trap('SIGINT') { raise Interrupt }
  3. Press ^C
Member

ddfreyne commented Feb 17, 2018

@gpakosz Does the problem persist when you do the following?

  1. bundle exec nanoc shell
  2. Signal.trap('SIGINT') { raise Interrupt }
  3. Press ^C
@gpakosz

This comment has been minimized.

Show comment
Hide comment
@gpakosz

gpakosz Feb 18, 2018

Member
Loading site… done
[1] pry(#<Nanoc::Int::Context>)> Signal.trap('SIGINT') { raise Interrupt }
=> #<Proc:0x00007f9d6815c950@/usr/local/lib/ruby/gems/2.5.0/gems/nanoc-4.8.16/lib/nanoc/cli/error_handler.rb:39>
[2] pry(#<Nanoc::Int::Context>)>
[2] pry(#<Nanoc::Int::Context>)>

Better!

Member

gpakosz commented Feb 18, 2018

Loading site… done
[1] pry(#<Nanoc::Int::Context>)> Signal.trap('SIGINT') { raise Interrupt }
=> #<Proc:0x00007f9d6815c950@/usr/local/lib/ruby/gems/2.5.0/gems/nanoc-4.8.16/lib/nanoc/cli/error_handler.rb:39>
[2] pry(#<Nanoc::Int::Context>)>
[2] pry(#<Nanoc::Int::Context>)>

Better!

@ddfreyne ddfreyne closed this in #1318 Feb 19, 2018

ddfreyne added a commit that referenced this issue Feb 19, 2018

Merge pull request #1318 from nanoc/gh-1309
Handle SIGINT in shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment