linux signal

This commit is contained in:
2022-11-01 09:38:27 +03:00
parent 591c92b4bb
commit e48d0ebaab
4 changed files with 10 additions and 5 deletions

View File

@@ -248,6 +248,10 @@
typedef long time_t;
#endif
#ifdef POSIX_SIGNALS
# define PIP_INTERRUPT_SIGNAL SIGTERM
#endif
#ifdef LINUX
# define environ __environ
#endif

View File

@@ -104,7 +104,8 @@ void pipInitThreadSignals() {
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = pipThreadSignalHandler;
sigaction(SIGUSR2, &actions, 0);
if (sigaction(PIP_INTERRUPT_SIGNAL, &actions, 0) != 0)
piCout << "sigaction error:" << errorString();
}
#endif

View File

@@ -608,7 +608,7 @@ void PIThread::interrupt() {
QueueUserAPC(winThreadAPC, PRIVATE->thread, 0);
#else
# ifdef POSIX_SIGNALS
pthread_kill(PRIVATE->thread, SIGUSR2);
pthread_kill(PRIVATE->thread, PIP_INTERRUPT_SIGNAL);
# endif
#endif
}

View File

@@ -80,7 +80,7 @@ public:
};
int main(int argc, char * argv[]) {
piCout << "main" << GetCurrentThreadId();
piCout << "main";
/*for (int i = 0; i < count; ++i)
pipes[i].create();
@@ -109,8 +109,8 @@ int main(int argc, char * argv[]) {
delete threads[i];
}*/
PIEthernet eth(PIEthernet::TCP_Client), seth(PIEthernet::TCP_Client);
eth.connect("192.168.1.13", 22);
PIEthernet eth(PIEthernet::UDP), seth(PIEthernet::TCP_Client);
eth.connect("127.0.0.1", 50000);
eth.startThreadedRead();
//piCout << eth.open();