File: libev.h

package info (click to toggle)
python-gevent 1.0.1-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,948 kB
  • ctags: 12,954
  • sloc: python: 39,061; ansic: 26,289; sh: 13,582; makefile: 833; awk: 18
file content (44 lines) | stat: -rw-r--r-- 875 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#if defined(LIBEV_EMBED)
#include "ev.c"
#else
#include "ev.h"

#ifndef _WIN32
#include <signal.h>
#endif

#endif

#ifndef _WIN32

static struct sigaction libev_sigchld;
static int sigchld_state = 0;

static struct ev_loop* gevent_ev_default_loop(unsigned int flags)
{
    if (sigchld_state)
        return ev_default_loop(flags);
    struct ev_loop* result;
    struct sigaction tmp;
    sigaction(SIGCHLD, NULL, &tmp);
    result = ev_default_loop(flags);
    // XXX what if SIGCHLD received there?
    sigaction(SIGCHLD, &tmp, &libev_sigchld);
    sigchld_state = 1;
    return result;
}


static void gevent_install_sigchld_handler(void) {
    if (sigchld_state == 1) {
        sigaction(SIGCHLD, &libev_sigchld, NULL);
        sigchld_state = 2;
    }
}

#else

#define gevent_ev_default_loop ev_default_loop
static void gevent_install_sigchld_handler(void) { }

#endif