Skip to content

Commit 71b4147

Browse files
authored
[3.9] bpo-41498: Fix build on platforms without sigset_t (GH-29770) (GH-29774)
Co-authored-by: Christian Heimes <[email protected]>
1 parent 151c9bf commit 71b4147

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Python now compiles on platforms without ``sigset_t``. Several functions
2+
in :mod:`signal` are not available when ``sigset_t`` is missing.
3+
4+
Based on patch by Roman Yurchak for pyodide.

Modules/clinic/signalmodule.c.h

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

+8
Original file line numberDiff line numberDiff line change
@@ -5882,6 +5882,7 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
58825882

58835883
}
58845884

5885+
#ifdef HAVE_SIGSET_T
58855886
if (setsigmask) {
58865887
sigset_t set;
58875888
if (!_Py_Sigset_Converter(setsigmask, &set)) {
@@ -5907,6 +5908,13 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
59075908
}
59085909
all_flags |= POSIX_SPAWN_SETSIGDEF;
59095910
}
5911+
#else
5912+
if (setsigmask || setsigdef) {
5913+
PyErr_SetString(PyExc_NotImplementedError,
5914+
"sigset is not supported on this platform");
5915+
goto fail;
5916+
}
5917+
#endif
59105918

59115919
if (scheduler) {
59125920
#ifdef POSIX_SPAWN_SETSCHEDULER

Modules/posixmodule.h

-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, gid_t *);
2323
# define HAVE_SIGSET_T
2424
#endif
2525

26-
#ifdef HAVE_SIGSET_T
2726
PyAPI_FUNC(int) _Py_Sigset_Converter(PyObject *, void *);
28-
#endif /* HAVE_SIGSET_T */
2927
#endif /* Py_LIMITED_API */
3028

3129
#ifdef __cplusplus

Modules/signalmodule.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ module signal
6868
[clinic start generated code]*/
6969
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b0301a3bde5fe9d3]*/
7070

71+
#ifdef HAVE_SETSIG_T
72+
7173
/*[python input]
7274
7375
class sigset_t_converter(CConverter):
@@ -76,6 +78,7 @@ class sigset_t_converter(CConverter):
7678
7779
[python start generated code]*/
7880
/*[python end generated code: output=da39a3ee5e6b4b0d input=b5689d14466b6823]*/
81+
#endif
7982

8083
/*
8184
NOTES ON THE INTERACTION BETWEEN SIGNALS AND THREADS
@@ -880,6 +883,7 @@ signal_getitimer_impl(PyObject *module, int which)
880883

881884
#endif
882885

886+
#ifdef HAVE_SIGSET_T
883887
#if defined(PYPTHREAD_SIGMASK) || defined(HAVE_SIGPENDING)
884888
static PyObject*
885889
sigset_to_set(sigset_t mask)
@@ -1011,9 +1015,9 @@ signal_sigwait_impl(PyObject *module, sigset_t sigset)
10111015
}
10121016

10131017
#endif /* #ifdef HAVE_SIGWAIT */
1018+
#endif /* #ifdef HAVE_SIGSET_T */
10141019

1015-
1016-
#if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
1020+
#if (defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)
10171021

10181022
/*[clinic input]
10191023
signal.valid_signals
@@ -1051,7 +1055,8 @@ signal_valid_signals_impl(PyObject *module)
10511055
#endif
10521056
}
10531057

1054-
#endif /* #if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS) */
1058+
#endif /* #if (defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS) */
1059+
10551060

10561061

10571062
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
@@ -1117,6 +1122,7 @@ fill_siginfo(siginfo_t *si)
11171122
}
11181123
#endif
11191124

1125+
#ifdef HAVE_SIGSET_T
11201126
#ifdef HAVE_SIGWAITINFO
11211127

11221128
/*[clinic input]
@@ -1219,6 +1225,7 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
12191225
}
12201226

12211227
#endif /* #ifdef HAVE_SIGTIMEDWAIT */
1228+
#endif /* #ifdef HAVE_SIGSET_T */
12221229

12231230

12241231
#if defined(HAVE_PTHREAD_KILL)

0 commit comments

Comments
 (0)