Skip to content

Hangs if the calling process ignores SIGCHLD #705

@yan12125

Description

@yan12125

For example, this program hangs unless I remove the call to signal function.

#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>

int main(void) {
    signal(SIGCHLD, SIG_IGN);

    pid_t pid = fork();

    if (pid == 0) {
        const char *argv[] = {
            "/usr/bin/bwrap",
            "--ro-bind", "/", "/",
            "--proc", "/proc",
            "/usr/bin/true",
            NULL
        };

        execv(argv[0], (char * const *)argv);
    }

    waitpid(pid, NULL, 0);

    return 0;
}

A real-world case is:

  • gcin, the affected application, uses signal(SIGCHLD, SIG_IGN);
  • gcin eventually uses glycin library
  • glycin uses bwrap

From gdb, bwrap is stuck in monitor_child. A fix might be using SIG_DFL for SIGCHLD before executing a process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions