mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fix: invalid return code
This commit is contained in:
parent
8f29e3d495
commit
f641b55355
2 changed files with 26 additions and 11 deletions
|
@ -241,8 +241,8 @@ static inline int log2i(long long x) {
|
|||
/** Sleep with rdtsc */
|
||||
void rdtsc_sleep(uint64_t nanosecs, uint64_t start);
|
||||
|
||||
/** Register a exit callback for program termination (SIGINT / SIGKILL). */
|
||||
void signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx));
|
||||
/** Register a exit callback for program termination: SIGINT, SIGKILL & SIGALRM. */
|
||||
int signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx));
|
||||
|
||||
/** Send signal \p sig to main thread. */
|
||||
void killme(int sig);
|
||||
|
|
33
lib/utils.c
33
lib/utils.c
|
@ -299,8 +299,10 @@ void rdtsc_sleep(uint64_t nanosecs, uint64_t start)
|
|||
}
|
||||
|
||||
/* Setup exit handler */
|
||||
void signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx))
|
||||
int signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx))
|
||||
{
|
||||
int ret;
|
||||
|
||||
info("Initialize signals");
|
||||
|
||||
struct sigaction sa_quit = {
|
||||
|
@ -308,19 +310,32 @@ void signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx))
|
|||
.sa_sigaction = cb
|
||||
};
|
||||
|
||||
main_thread = pthread_self();
|
||||
|
||||
sigemptyset(&sa_quit.sa_mask);
|
||||
sigaction(SIGINT, &sa_quit, NULL);
|
||||
sigaction(SIGTERM, &sa_quit, NULL);
|
||||
sigaction(SIGALRM, &sa_quit, NULL);
|
||||
|
||||
struct sigaction sa_chld = {
|
||||
.sa_flags = 0,
|
||||
.sa_handler = SIG_IGN
|
||||
};
|
||||
|
||||
main_thread = pthread_self();
|
||||
|
||||
sigaction(SIGCHLD, &sa_chld, NULL);
|
||||
sigemptyset(&sa_quit.sa_mask);
|
||||
|
||||
ret = sigaction(SIGINT, &sa_quit, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = sigaction(SIGTERM, &sa_quit, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = sigaction(SIGALRM, &sa_quit, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = sigaction(SIGCHLD, &sa_chld, NULL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void killme(int sig)
|
||||
|
|
Loading…
Add table
Reference in a new issue