sigemptyset(&sigmask);
sigaddset(&sigmask, SIGCHLD);
- /* Block SIGCHLD so that it becomes readable via signalfd */
- ret = sigprocmask(SIG_BLOCK, &sigmask, NULL);
- if (ret < 0) {
- pr_err("Failed to sigprocmask: %m\n");
- }
-
signal_handler.fd = signalfd(-1, &sigmask, SFD_CLOEXEC);
if (job_request_handler.fd < 0) {
pr_err("Failed to create signal_fd: %m\n");
for (i = 0; i < max_jobs; i++)
pthread_create(&thread[i], NULL, worker_thread, (void *)i);
- /*
- * Magic sleep. There are too many fork() calls at the moment
- * so we must ensure our threads don't print anything out
- * while a fork() is executed. Otherwise the child will
- * inherit glibc internal locks while they are locked, and
- * function calls such as printf will deadlock.
- */
- sleep(1);
-
return 0;
}