#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/neutrino.h>
static void handler(int signo, siginfo_t* info, void* context) {
cout << "SIG = " << signo << ";
TID = " << pthread_self() << endl;
}
sigset_t sig;
void* threadfunc(void* data) {
SignalProcmask(0, 0, SIG_UNBLOCK, &sig, NULL);
while (true) pause();
}
int main() {
sigemptyset(&sig);
sigaddset(&sig, SIGRTMIN);
sigprocmask(SIG_BLOCK, &sig, NULL);
cout << "Process " << getpid() << ", waiting for signal " <<
SIGRTMIN << endl;
struct sigaction act;
act.sa_mask = sig;
act.sa_sigaction = handler;
act.sa_flags = SA_SIGINFO;
if (sigaction(SIGRTMIN, &act, NULL) < 0)
perror("set signal handler: ");
const int thrnum = 3;
for (int i = 0; i < thrnum; i++)
pthread_create(NULL, NULL, threadfunc, NULL);
pause();
exit(EXIT_SUCCESS);