/* $Id: tf.c,v 1.3 2008/12/01 15:40:23 kostik Exp kostik $ */ #include #include #include #include #include #include #include #include static void report_sigchld(void) { int err; sigset_t oset; err = pthread_sigmask(SIG_BLOCK, NULL, &oset); if (err != 0) { fprintf(stderr, "pthread_sigmask: %s\n", strerror(errno)); return; } if (sigismember(&oset, SIGCHLD)) printf("SIGCHLD is blocked\n"); else printf("SIGCHLD is enabled\n"); } static void * mythr(void *arg) { int child; printf("Hello\n"); report_sigchld(); child = fork(); if (child == -1) { fprintf(stderr, "fork2: %s\n", strerror(errno)); return (NULL); } else if (child == 0) { report_sigchld(); /* XXX I know */ } return (NULL); } int main(int argc, char *argv[]) { int child, err; pthread_t thr; pthread_mutex_t m; report_sigchld(); err = pthread_create(&thr, NULL, mythr, NULL); if (err != 0) { fprintf(stderr, "pthread_create: %s\n", strerror(errno)); exit(1); } err = pthread_join(thr, NULL); if (err != 0) { fprintf(stderr, "pthread_create: %s\n", strerror(errno)); exit(1); } exit(0); }