diff options
author | Rom Lemarchand <romlem@google.com> | 2013-01-16 15:07:30 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-01-29 00:05:24 +0000 |
commit | ed179d2f98c1628a593aec6d8408b621015f4de5 (patch) | |
tree | c32ad253c09801427641811d3cd6eb75bef575d1 | |
parent | 75c289aab9b81dc2235680cf141a4b183ee49391 (diff) | |
download | system_core-ed179d2f98c1628a593aec6d8408b621015f4de5.zip system_core-ed179d2f98c1628a593aec6d8408b621015f4de5.tar.gz system_core-ed179d2f98c1628a593aec6d8408b621015f4de5.tar.bz2 |
logwrap: Replace sigprocmask with pthread_sigmask
sigprocmask has undefined behavior when called from a thread.
Replacing with pthread_sigmask to ensure correct behavior if
logwrap() gets called from a thread.
Change-Id: I77b6959d345eac8d7b90039ed8144ead8c19a00c
-rw-r--r-- | logwrapper/logwrap.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/logwrapper/logwrap.c b/logwrapper/logwrap.c index 99a462f..94e0229 100644 --- a/logwrapper/logwrap.c +++ b/logwrapper/logwrap.c @@ -69,7 +69,7 @@ static int parent(const char *tag, int parent_read, int signal_fd, pid_t pid, sigemptyset(&chldset); sigaddset(&chldset, SIGCHLD); - sigprocmask(SIG_UNBLOCK, &chldset, NULL); + pthread_sigmask(SIG_UNBLOCK, &chldset, NULL); while (!found_child) { if (poll(poll_fds, remote_hung ? 1 : 2, -1) < 0) { @@ -209,7 +209,7 @@ int logwrap(int argc, char* argv[], int *status, bool ignore_int_quit) { sigaddset(&blockset, SIGINT); sigaddset(&blockset, SIGQUIT); sigaddset(&blockset, SIGCHLD); - sigprocmask(SIG_BLOCK, &blockset, &oldset); + pthread_sigmask(SIG_BLOCK, &blockset, &oldset); pid = fork(); if (pid < 0) { @@ -217,7 +217,7 @@ int logwrap(int argc, char* argv[], int *status, bool ignore_int_quit) { rc = -1; goto err_fork; } else if (pid == 0) { - sigprocmask(SIG_SETMASK, &oldset, NULL); + pthread_sigmask(SIG_SETMASK, &oldset, NULL); close(parent_ptty); child_ptty = open(child_devname, O_RDWR); @@ -287,7 +287,7 @@ err_socketpair: } sigaction(SIGCHLD, &oldchldact, NULL); err_fork: - sigprocmask(SIG_SETMASK, &oldset, NULL); + pthread_sigmask(SIG_SETMASK, &oldset, NULL); err_ptty: close(parent_ptty); err_open: |