aboutsummaryrefslogtreecommitdiff
path: root/src/sgp_dd.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2017-12-29 18:23:19 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2017-12-29 18:23:19 +0000
commitb29ef85867d5347e8fed4c603986964868cba801 (patch)
tree6c39b1855f97dc416307229654713d9aed4c8d54 /src/sgp_dd.c
parent766b77d70276eef4a6ae92217d1ffbcde819a88b (diff)
downloadsg3_utils-b29ef85867d5347e8fed4c603986964868cba801.tar.gz
sg_ses: further NVMe support work; decode array status dpage (obsolete); build: add SG_LIB_ANDROID
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@738 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src/sgp_dd.c')
-rw-r--r--src/sgp_dd.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/sgp_dd.c b/src/sgp_dd.c
index f6cf2a6b..bb515c82 100644
--- a/src/sgp_dd.c
+++ b/src/sgp_dd.c
@@ -60,7 +60,7 @@
#include "sg_pr2serr.h"
-static const char * version_str = "5.58 20171209";
+static const char * version_str = "5.59 20171222";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -272,6 +272,14 @@ install_handler(int sig_num, void (*sig_handler) (int sig))
}
}
+#ifdef SG_LIB_ANDROID
+static void
+thread_exit_handler(int sig)
+{
+ pthread_exit(0);
+}
+#endif
+
/* Make safe_strerror() thread safe */
static char *
tsafe_strerror(int code, char * ebp)
@@ -1147,7 +1155,15 @@ main(int argc, char * argv[])
int in_sect_sz, out_sect_sz, status, n, flags;
void * vp;
char ebuff[EBUFF_SZ];
-
+#if SG_LIB_ANDROID
+ struct sigaction actions;
+
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_exit_handler;
+ sigaction(SIGUSR1, &actions, NULL);
+#endif
memset(&rcoll, 0, sizeof(Rq_coll));
rcoll.bpt = DEF_BLOCKS_PER_TRANSFER;
rcoll.in_type = FT_OTHER;
@@ -1629,7 +1645,13 @@ main(int argc, char * argv[])
}
}
+#if SG_LIB_ANDROID
+ /* Android doesn't have pthread_cancel() so use pthread_kill() instead.
+ * Also there is no need to link with -lpthread in Android */
+ status = pthread_kill(sig_listen_thread_id, SIGUSR1);
+#else
status = pthread_cancel(sig_listen_thread_id);
+#endif
if (0 != status) err_exit(status, "pthread_cancel");
if (STDIN_FILENO != rcoll.infd)
close(rcoll.infd);