Resetting Signal Mask

Thomas Guettler hv at tbz-pariv.de
Fri Jan 4 09:03:25 CET 2008


Hi,

with mod_wsgi (apache2) a process created with os.system()
has a modified signal mask, that SIGPWR gets ignored.

A small wrapper (see bottom) resets the signal mask and uses execv to
run the programm.

Unfortunately python does not support sigprocmask. Is there
any other way to reset the signal mask? I guess it could
be done with ctypes (I never used it up to now).

Why is sigprocmask not available in Python? Python exposes most of the other
POSIX API.

 Thomas

      1 #include <signal.h>
      2 #include <unistd.h>
      3 #include <stdio.h>
      4
      5 int main(int argc, char *argv[]) {
      6   sigset_t  newmask;
      7
      8   sigemptyset(&newmask);
      9   sigprocmask(SIG_SETMASK, &newmask, NULL);
     10   int ret=execv(argv[1], &argv[1]);
     11   if (ret != 0) { perror(argv[0]); }
     12   return ret;
     13 }



More information about the Python-list mailing list