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

Kill should accept signal names, not just numbers #11

Closed
mgedmin opened this issue Apr 15, 2015 · 6 comments
Closed

Kill should accept signal names, not just numbers #11

mgedmin opened this issue Apr 15, 2015 · 6 comments

Comments

@mgedmin
Copy link
Member

mgedmin commented Apr 15, 2015

These three should be equivalent

zdaemon kill 12
zdaemon kill USR2
zdaemon kill SIGUSR2
@freddrake
Copy link
Contributor

zc.signalhandler (https://pypi.python.org/pypi/zc.signalhandler/) has code you can rip off. Not that it's hard to write, but... why bother re-inventing?

@mgedmin
Copy link
Member Author

mgedmin commented Apr 15, 2015

zc.signalhandler is not on GitHub

😢

@mgedmin
Copy link
Member Author

mgedmin commented Apr 15, 2015

Now it is :)

@mgedmin
Copy link
Member Author

mgedmin commented Apr 15, 2015

Eh, name2signal from zc.signalhandler kind of does the opposite of what I need: converts signal numbers or names to names.

I can do getattr(signal, name2signal(arg)), I suppose, to convert it back into a number.

mgedmin added a commit that referenced this issue Apr 15, 2015
Uses name2signal() copied and pasted from zc.signalhandler.

Adds a test for the previously-untested do_kill().
@mgedmin mgedmin closed this as completed Apr 15, 2015
@freddrake
Copy link
Contributor

Gosh, you closed this before I could respond to your comments.

Since you had to copy name2signal, you could have modified it to return the signal number instead of the normalized name. That would have avoided the awkward extra step.

Fortunately, that's still possible with another commit. :-)

@mgedmin
Copy link
Member Author

mgedmin commented Apr 15, 2015

Instead I decided to grab the opportunity to change the output to print the name of the signal being sent, instead of the number.

(Hm, there's already another number-to-name conversion function in zdrun.py. Perhaps something could be refactored there. I won't object ;-)

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

No branches or pull requests

2 participants