- sigemptyset(&ss);
- while ((r = read(fd, buf, sizeof(buf))) > 0) {
- unsigned char *p, *q;
- for (p = buf, q = buf + r; p < q; p++) {
+ /* --- Read the currently caught signals --- *
+ *
+ * Block signals while the mask is being copied.
+ */
+
+ {
+ sigset_t oss;
+ unsigned char buf[256];
+
+ sigprocmask(SIG_BLOCK, &ss_all, &oss);
+ ss = ss_caught;
+ sigemptyset(&ss_caught);
+ while (read(fd, buf, sizeof(buf)) > 0)
+ /* Do nothing */;
+ sigprocmask(SIG_SETMASK, &oss, 0);
+ }
+
+ /* --- Process the caught signals --- */
+
+ {
+ int i;
+ for (i = 0; i < nsig; i++) {