start move to interruption of blocking calls, PIThread and PIEthernet

This commit is contained in:
2022-11-01 00:02:44 +03:00
parent ca403ca2c7
commit 6e81a419fb
8 changed files with 311 additions and 57 deletions

View File

@@ -22,6 +22,10 @@
#include "picout.h"
#ifdef WINDOWS
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0600
# endif
# include <stdarg.h>
# include <windef.h>
# include <winbase.h>

View File

@@ -92,9 +92,19 @@ void __sighandler__(PISignals::Signal s) {
}
#ifdef ANDROID
void android_thread_exit_handler(int sig) {
pthread_exit(0);
#ifdef POSIX_SIGNALS
void pipThreadSignalHandler(int sig) {
//# ifdef ANDROID
// pthread_exit(0);
//# endif
}
void pipInitThreadSignals() {
struct sigaction actions;
memset(&actions, 0, sizeof(actions));
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = pipThreadSignalHandler;
sigaction(SIGUSR2, &actions, 0);
}
#endif
@@ -166,14 +176,10 @@ PIInit::PIInit() {
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C");
# endif //HAS_LOCALE
#else //ANDROID
struct sigaction actions;
memset(&actions, 0, sizeof(actions));
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = android_thread_exit_handler;
sigaction(SIGTERM, &actions, 0);
#endif //ANDROID
#ifdef POSIX_SIGNALS
pipInitThreadSignals();
#endif
PRIVATE->delete_locs = false;
__syslocname__ = __sysoemname__ = 0;
__utf8name__ = const_cast<char*>("UTF-8");