summaryrefslogtreecommitdiffstats
path: root/pigz
diff options
context:
space:
mode:
authorEthan Yonker <dees_troy@teamw.in>2015-10-09 18:15:26 +0200
committerEthan Yonker <dees_troy@teamw.in>2015-10-09 18:15:29 +0200
commitc798c9cd2486e0ff83776002c74f113677b10a84 (patch)
treed128a80cbc58e63a622fda2774e727611f9d2cd4 /pigz
parentAdd TW_IGNORE_ABS_MT_TRACKING_ID (diff)
parentmerge in mnc-release history after reset to mnc-dev (diff)
downloadandroid_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.tar
android_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.tar.gz
android_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.tar.bz2
android_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.tar.lz
android_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.tar.xz
android_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.tar.zst
android_bootable_recovery-c798c9cd2486e0ff83776002c74f113677b10a84.zip
Diffstat (limited to 'pigz')
-rw-r--r--pigz/yarn.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/pigz/yarn.c b/pigz/yarn.c
index 5e557f3f1..74db3fb4e 100644
--- a/pigz/yarn.c
+++ b/pigz/yarn.c
@@ -31,6 +31,7 @@
#include <stdio.h> /* fprintf(), stderr */
#include <stdlib.h> /* exit(), malloc(), free(), NULL */
#include <pthread.h> /* pthread_t, pthread_create(), pthread_join(), */
+#include <signal.h> /* sigaction, SIGUSR1 */
/* pthread_attr_t, pthread_attr_init(), pthread_attr_destroy(),
PTHREAD_CREATE_JOINABLE, pthread_attr_setdetachstate(),
pthread_self(), pthread_equal(),
@@ -39,6 +40,7 @@
pthread_cond_t, PTHREAD_COND_INITIALIZER, pthread_cond_init(),
pthread_cond_broadcast(), pthread_cond_wait(), pthread_cond_destroy() */
#include <errno.h> /* ENOMEM, EAGAIN, EINVAL */
+#include <string.h> /* memset */
/* interface definition */
#include "yarn.h"
@@ -50,6 +52,11 @@
char *yarn_prefix = "yarn";
void (*yarn_abort)(int) = NULL;
+void thread_exit_handler(int sig)
+{
+ printf("this signal is %d \n", sig);
+ pthread_exit(0);
+}
/* immediately exit -- use for errors that shouldn't ever happen */
local void fail(int err)
@@ -263,6 +270,13 @@ thread *launch(void (*probe)(void *), void *payload)
thread *th;
struct capsule *capsule;
pthread_attr_t attr;
+ struct sigaction actions;
+
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_exit_handler;
+ ret = sigaction(SIGUSR1,&actions,NULL);
/* construct the requested call and argument for the ignition() routine
(allocated instead of automatic so that we're sure this will still be
@@ -369,7 +383,7 @@ void destruct(thread *off_course)
{
int ret;
- if ((ret = pthread_cancel(off_course->id)) != 0)
+ if ((ret = pthread_kill(off_course->id, SIGUSR1)) != 0)
fail(ret);
join(off_course);
}