[package] uhttpd: block SIGCHLD until it is expected (#6957)
[openwrt-10.03/.git] / package / uhttpd / src / uhttpd-utils.c
index c1e08b069586b2ee5484d05a97b61cde4c4da325..55b2c410e35714702bfd6aaf0d8159ca8076e693 100644 (file)
@@ -88,6 +88,25 @@ char *strfind(char *haystack, int hslen, const char *needle, int ndlen)
        return NULL;
 }
 
+/* interruptable select() */
+int select_intr(int n, fd_set *r, fd_set *w, fd_set *e, struct timeval *t)
+{
+       int rv;
+       sigset_t ssn, sso;
+
+       /* unblock SIGCHLD */
+       sigemptyset(&ssn);
+       sigaddset(&ssn, SIGCHLD);
+       sigprocmask(SIG_UNBLOCK, &ssn, &sso);
+
+       rv = select(n, r, w, e, t);
+
+       /* restore signal mask */
+       sigprocmask(SIG_SETMASK, &sso, NULL);
+
+       return rv;
+}
+
 
 int uh_tcp_send(struct client *cl, const char *buf, int len)
 {