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

Enable trap function accept Integer(Non-String) #976

Merged
merged 1 commit into from
May 5, 2023

Conversation

MasanoriOnishi
Copy link
Contributor

Description

In the following code, Signal.#trap method is overridden.
https://github.com/ruby/debug/blob/v1.7.2/lib/debug/session.rb#L2520

Although the original trap code can accept Integer, the above can't.

That's why I enabled trap function accept Integer(Non-String).

Relates to #975

@ko1 ko1 merged commit f4b4dda into ruby:master May 5, 2023
ko1 pushed a commit that referenced this pull request May 5, 2023
ko1 pushed a commit that referenced this pull request May 5, 2023
@@ -2524,7 +2524,7 @@ def daemon(*args)

module TrapInterceptor
def trap sig, *command, &command_proc
case sig&.to_sym
case sig&.to_s&.to_sym

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't handle integers correctly, because they won't fall into :INT and :SIGINT below. This would do it:

      case sig&.to_s&.to_sym
      when :INT, :SIGINT, :"2"
        if defined?(SESSION) && SESSION.active? && SESSION.intercept_trap_sigint?
          return SESSION.save_int_trap(command.empty? ? command_proc : command.first)
        end
      end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed your comment. Could you make an issue or PR for it with examples?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ko1 Nevermind, you already fixed this in #976 :)

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

Successfully merging this pull request may close these issues.

None yet

3 participants