Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions native/jni/native-lib/cpproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ int cpproc_forkAndExec (char * const *commandLine, char * const * newEnviron,
int fail_fds[2];
const char *path;
char **sh_argv;
sigset_t allsigs;
sigset_t savedmask;
int errnum;
ssize_t n;
int argc;
Expand Down Expand Up @@ -141,6 +143,11 @@ int cpproc_forkAndExec (char * const *commandLine, char * const * newEnviron,
return err;
}

/* Block all signals before we fork() to ensure that the child's
setup is not interrupted, so no call can fail with EINTR. */
sigfillset(&allsigs);
pthread_sigmask(SIG_SETMASK, &allsigs, &savedmask);

pid = fork();

switch (pid)
Expand All @@ -155,13 +162,15 @@ int cpproc_forkAndExec (char * const *commandLine, char * const * newEnviron,
{
int err = errno;

pthread_sigmask(SIG_SETMASK, &savedmask, NULL);
close_fds(local_fds, pipe_count * 2);
close(fail_fds[0]);
close(fail_fds[1]);
free(sh_argv);
return err;
}
default:
pthread_sigmask(SIG_SETMASK, &savedmask, NULL);
free(sh_argv);
close(fail_fds[1]);

Expand Down
Loading