Files
termux-packages/packages/pikiwidb/pthread_cancel.patch
termux-pacman-bot 527e3f4d22 bump(main/pikiwidb): 3.5.6
- Project external branding renamed to "pikiwidb"; internal branding, configuration file name, and executable name still "pika"

- New dependencies `fmt`, `gflags`, `zlib`

- Switched to CMake

- Rewrite all patches; many dependencies had to be unvendored and build for Android forced

- Enable 32-bit ARM target

- Tested and appears to be working rootless on a standard device as long as "`eth1`" is changed to "`wlan0`" in the configuration file and then the modified configuration file is specified using `pika -c /path/to/modified/pika.conf`.
2026-01-02 23:37:20 +00:00

47 lines
1.3 KiB
Diff

--- a/src/pstd/src/posix.cc
+++ b/src/pstd/src/posix.cc
@@ -8,6 +8,15 @@
* Wrappers for Unix process control functions
********************************************/
+#ifdef __ANDROID__
+#define PTHREAD_CANCELED ((void *)-1)
+static void
+thread_signal_handler(int signum)
+{
+ pthread_exit(PTHREAD_CANCELED);
+}
+#endif
+
/* $begin forkwrapper */
pid_t Fork() {
pid_t pid;
@@ -397,6 +406,15 @@ struct hostent* Gethostbyaddr(const char* addr, int len, int type) {
void Pthread_create(pthread_t* tidp, pthread_attr_t* attrp, void* (*routine)(void*), void* argp) {
int rc;
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
+
if (rc = pthread_create(tidp, attrp, routine, argp); rc != 0) {
LOG(ERROR) << "Pthread_create error: " << strerror(rc);
}
@@ -405,7 +423,11 @@ void Pthread_create(pthread_t* tidp, pthread_attr_t* attrp, void* (*routine)(voi
void Pthread_cancel(pthread_t tid) {
int rc;
+#ifdef __ANDROID__
+ if (rc = pthread_kill(tid, SIGUSR2); rc != 0) {
+#else
if (rc = pthread_cancel(tid); rc != 0) {
+#endif
LOG(ERROR) << "Pthread_cancel error: " << strerror(rc);
}
}