mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
utils: move killme() to C++ code in order to avoid global objects
This commit is contained in:
parent
aa1ce97a1f
commit
0c711c79c9
3 changed files with 15 additions and 13 deletions
|
@ -37,8 +37,6 @@ extern "C" {
|
|||
#include <villas/config.h>
|
||||
#include <villas/log.h>
|
||||
|
||||
extern pthread_t main_thread;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define LIKELY(x) __builtin_expect((x),1)
|
||||
#define UNLIKELY(x) __builtin_expect((x),0)
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <villas/config.h>
|
||||
#include <villas/utils.h>
|
||||
|
||||
pthread_t main_thread;
|
||||
|
||||
double box_muller(float m, float s)
|
||||
{
|
||||
double x1, x2, y1;
|
||||
|
@ -113,15 +111,6 @@ void * memdup(const void *src, size_t bytes)
|
|||
return dst;
|
||||
}
|
||||
|
||||
void killme(int sig)
|
||||
{
|
||||
/* Send only to main thread in case the ID was initilized by signals_init() */
|
||||
if (main_thread)
|
||||
pthread_kill(main_thread, sig);
|
||||
else
|
||||
kill(0, sig);
|
||||
}
|
||||
|
||||
pid_t spawn(const char* name, char *const argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
namespace villas {
|
||||
namespace utils {
|
||||
|
||||
static pthread_t main_thread;
|
||||
|
||||
std::vector<std::string>
|
||||
tokenize(std::string s, std::string delimiter)
|
||||
{
|
||||
|
@ -156,5 +158,18 @@ char * decolor(char *str)
|
|||
return str;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void killme(int sig)
|
||||
{
|
||||
/* Send only to main thread in case the ID was initilized by signals_init() */
|
||||
if (main_thread)
|
||||
pthread_kill(main_thread, sig);
|
||||
else
|
||||
kill(0, sig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
} // namespace villas
|
||||
|
|
Loading…
Add table
Reference in a new issue