1 /* Main body: wait something to report */
3 if ((n=epoll_wait(epfd, events, MAX_EPOLL_EV, -1)) < 0)
4 die("error on epoll_wait");
5 for (i=0; i<n; i++) { // loop on ready file descriptors
6 if (events[i].data.fd == sigfd) { // look if signalfd ready
7 printf("Signal received:\n");
8 while(nread=read(sigfd, &siginf, sizeof(siginf))) {
11 die("signalfd read error");
15 if (nread != sizeof(siginf)) {
16 printf("Error on signal data read, '\n");
19 printf("Got %s\n", sig_names[siginf.ssi_signo]);
20 printf("From pid %i\n", siginf.ssi_pid);
21 if(siginf.ssi_signo == SIGINT) { // SIGINT stop program
26 } else if (events[i].data.fd == fifofd) { // look if fifofd ready
27 printf("Message from fifo:\n");
28 while ((nread = read(fifofd, buffer, 5000))) {
31 die("fifo read error");
33 printf("end message\n");
37 if (fputs(buffer, stdout) == EOF)
38 die("Errore in scrittura su terminale");
40 } else { // anything else is an error
41 printf("epoll activity on unknown %i file descriptor\n",