Untitled

mail@pastecode.io avatar
unknown
c_cpp
3 years ago
602 B
2
Indexable
Never
int main(void) {
    int fds[2];
    pipe(fds);

    sigset_t psel;
    sigemptyset(&psel);
    sigaddset(&psel,SIGTERM);

    struct sigaction s;
    memset(&s,0, sizeof(s));

    s.sa_handler=handle_sig;
    s.sa_flags=0;
    sigaction(SIGTERM,&s,NULL);

    fd_set current_sockets;

    //inizializzo i set
    FD_ZERO(&current_sockets);
    FD_SET(fds[0], &current_sockets);    //aggiungo un socket nel set
    int max_sockets = fds[0];

    while (run){}

    printf("Ascolto....\n\n");
    pselect(max_sockets+1,&current_sockets,NULL,NULL,NULL, &psel);
    printf("bye bye...\n");
    return 0;
}