##// END OF EJS Templates
osutil: add a function to unblock signals...
Jun Wu -
r35476:8652ab40 default
parent child Browse files
Show More
@@ -20,6 +20,7 b''
20 20 #include <windows.h>
21 21 #else
22 22 #include <dirent.h>
23 #include <signal.h>
23 24 #include <sys/socket.h>
24 25 #include <sys/stat.h>
25 26 #include <sys/types.h>
@@ -1111,6 +1112,25 b' static PyObject *getfstype(PyObject *sel'
1111 1112 }
1112 1113 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */
1113 1114
1115 static PyObject *unblocksignal(PyObject *self, PyObject *args)
1116 {
1117 int sig = 0;
1118 int r;
1119 if (!PyArg_ParseTuple(args, "i", &sig))
1120 return NULL;
1121 sigset_t set;
1122 r = sigemptyset(&set);
1123 if (r != 0)
1124 return PyErr_SetFromErrno(PyExc_OSError);
1125 r = sigaddset(&set, sig);
1126 if (r != 0)
1127 return PyErr_SetFromErrno(PyExc_OSError);
1128 r = sigprocmask(SIG_UNBLOCK, &set, NULL);
1129 if (r != 0)
1130 return PyErr_SetFromErrno(PyExc_OSError);
1131 Py_RETURN_NONE;
1132 }
1133
1114 1134 #endif /* ndef _WIN32 */
1115 1135
1116 1136 static PyObject *listdir(PyObject *self, PyObject *args, PyObject *kwargs)
@@ -1291,6 +1311,8 b' static PyMethodDef methods[] = {'
1291 1311 {"getfstype", (PyCFunction)getfstype, METH_VARARGS,
1292 1312 "get filesystem type (best-effort)\n"},
1293 1313 #endif
1314 {"unblocksignal", (PyCFunction)unblocksignal, METH_VARARGS,
1315 "change signal mask to unblock a given signal\n"},
1294 1316 #endif /* ndef _WIN32 */
1295 1317 #ifdef __APPLE__
1296 1318 {
@@ -1301,7 +1323,7 b' static PyMethodDef methods[] = {'
1301 1323 {NULL, NULL}
1302 1324 };
1303 1325
1304 static const int version = 1;
1326 static const int version = 2;
1305 1327
1306 1328 #ifdef IS_PY3K
1307 1329 static struct PyModuleDef osutil_module = {
@@ -74,7 +74,7 b' def _importfrom(pkgname, modname):'
74 74 (r'cext', r'bdiff'): 1,
75 75 (r'cext', r'diffhelpers'): 1,
76 76 (r'cext', r'mpatch'): 1,
77 (r'cext', r'osutil'): 1,
77 (r'cext', r'osutil'): 2,
78 78 (r'cext', r'parsers'): 4,
79 79 }
80 80
@@ -163,6 +163,10 b' try:'
163 163 setprocname = osutil.setprocname
164 164 except AttributeError:
165 165 pass
166 try:
167 unblocksignal = osutil.unblocksignal
168 except AttributeError:
169 pass
166 170
167 171 # Python compatibility
168 172
General Comments 0
You need to be logged in to leave comments. Login now