-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-34412: strsignal(3) does not exist on HP-UX #8786
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
Conversation
Modules/signalmodule.c
Outdated
@@ -530,7 +530,7 @@ signal_strsignal_impl(PyObject *module, int signalnum) | |||
return NULL; | |||
} | |||
|
|||
#ifdef MS_WINDOWS | |||
#ifndef HAVE_STRSIGNAL | |||
/* Custom redefinition of POSIX signals allowed on Windows */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is now somewhat inaccurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall I drop it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep it and add HP-UX instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Please add a NEWS entry. See https://devguide.python.org/committing/#what-s-new-and-news-entries for details.
-
Please regenerate
configure
. -
Does the
test_strsignal
test inLib/test/test_signal.py
passed on HP-UX when you applied this patch?
configure.ac
Outdated
@@ -5541,6 +5541,15 @@ AC_MSG_RESULT(python) | |||
AC_DEFINE(PY_SSL_DEFAULT_CIPHERS, 1) | |||
]) | |||
|
|||
# Windows and HP-UX do not support strsignal(3) | |||
AC_MSG_CHECKING(for strsignal) | |||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we add strsignal
to the list at https://github.com/python/cpython/blob/7980d771c76d55aca55e1e619bada7c4707305b2/configure.ac#L3433 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have considered this, but it is nowhere documented that it will include string.h
. I went for the safe bet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of the functions listed there require a header file to be included and none of them are documented in the autoconf documentation. For example, alarm()
requires unistd.h
and Modules/signalmodule.c
already uses it:
Does that check works on HP-UX? If it works, I think we can try adding signalstr
to that list.
Currently, configure.ac
is a mess, so it would nice if we can keep it shorter :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just check on FreeBSD and HP-UX. It does its job in both config.log
and config.status
for both platforms. Will change accordingly.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Output:
|
26627f0
to
20df665
Compare
I have made the requested changes; please review again |
Thanks for making the requested changes! @berkerpeksag: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a typo in your test:
======================================================================
ERROR: test_strsignal (test.test_signal.PosixTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/python/cpython/Lib/test/test_signal.py", line 66, in test_strsignal
self.assertIn("Hangup", signal.strsignal(singal.SIGHUP))
NameError: name 'singal' is not defined
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Lib/test/test_signal.py
Outdated
@@ -60,6 +60,10 @@ def test_getsignal(self): | |||
def test_strsignal(self): | |||
self.assertIn("Interrupt", signal.strsignal(signal.SIGINT)) | |||
self.assertIn("Terminated", signal.strsignal(signal.SIGTERM)) | |||
if sys.platform.startswith("hp-ux"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SIGHUP
is a pretty common signal, so it can be added to the list in Modules/signalmodule.c
:
#ifndef MS_WINDOWS
/* TODO: Add a comment to explain why we need this on HP-UX. */
case SIGHUP:
res = "Hangup";
break;
#endif
Then we can test self.assertIn("Hangup", signal.strsignal(singal.SIGHUP))
unconditionally.
@@ -0,0 +1 @@ | |||
Add HAVE_STRSIGNAL to avoid build failure on HP-UX with strsignal(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we say something like "make :func:`signal.strsignal` work on HP-UX"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add "Patch by Your Name.".
391f445
to
bdc1a80
Compare
I have made the requested changes; please review again |
Thanks for making the requested changes! @tiran, @berkerpeksag: please review the changes made to this pull request. |
There are test failures on Windows because |
Did you cover it with |
So you are looking for this:
This isn't there, I can add this. Shall I? |
@berkerpeksag Change pushed. |
I have made the requested changes; please review again |
Thanks for making the requested changes! @tiran, @berkerpeksag: please review the changes made to this pull request. |
@@ -0,0 +1 @@ | |||
make :func:`signal.strsignal` work on HP-UX. Patch by Michael Osipov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: make -> Make
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
Modules/signalmodule.c
Outdated
switch (signalnum) { | ||
/* Though being a UNIX, HP-UX does not provide strsignal(3) */ | ||
#ifndef MS_WINDOWS | ||
case SIGHUP: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list was just a redefinition of POSIX signals supported by Windows. I think we need to check whether there is more than one signal to add to this list for other Unix systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I can go through signal.h
on HP-UX and provide those, but this is out of scope of this PR because the motivation for this one is just to make this module properly compile on HP-UX. Is that OK for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@berkerpeksag I went through signal.h
. There is a bus load of signals, some wrapped with ifdefs. I don't think that HP-UX is worth the effort for now just to have a nice string. If so, this has to be a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely can't maintain a full list of signals for every platform we support, so I agree with you. I was wondering whether there are other signals to include to make strsignal()
useful for most common cases.
I just checked http://nixdoc.net/man-pages/hp-ux/man5/signal.5.html and I think the most common unlisted signals are SIGALRM, SIGPIPE, SIGQUIT, and SIGCHLD.
Since SIGINT and SIGTERM is already in the list, I'd expect SIGQUIT to be there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I added all those. checked FreeBSD and glibc implementation + manpages and took the strings (_sys_siglist[]
) out of them. They are identical. I am sure whether the tests should be extented because the Open Group says about strsignal(3)
that the return value is implementation-defined.
@berkerpeksag WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks! No need to update the tests.
I will take another look at this and merge tonight.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again |
Thanks for making the requested changes! @tiran, @berkerpeksag: please review the changes made to this pull request. |
@berkerpeksag are we good to merge? |
@michael-o could you rerun autoreconf and commit the changes in diff --git a/pyconfig.h.in b/pyconfig.h.in
index d80ddc0..a82c373 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -984,6 +984,9 @@
/* Define to 1 if you have the <stropts.h> header file. */
#undef HAVE_STROPTS_H
+/* Define to 1 if you have the `strsignal' function. */
+#undef HAVE_STRSIGNAL
+
/* Define to 1 if `pw_gecos' is a member of `struct passwd'. */
#undef HAVE_STRUCT_PASSWD_PW_GECOS
|
Addressed in the latest review. Thanks!
Introduce a configure check for strsignal(3) which defines HAVE_STRSIGNAL for signalmodule.c. This change applies for Windows and HP-UX. Patch by Michael Osipov.
I have made the requested changes; please review again @berkerpeksag Done. Should be fine now. Have a look please. |
Thanks for making the requested changes! @berkerpeksag: please review the changes made to this pull request. |
Thanks! |
@berkerpeksag Thanks for merging. Would you mind to take a look at my other HP-UX related PRs? I'd like to continue contributing. |
@michael-o I'm looking at #8846 and #8828, but the PRs about |
Introduce a configure check for strsignal(3) and define HAVE_STRSIGNAL for
signalmodule.c. This change applies for Windows and HP-UX.
https://bugs.python.org/issue34412