flock implemented
This commit is contained in:
13
src/main.c
13
src/main.c
@@ -171,15 +171,19 @@ static void *display_thread(void *arg) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
control.g_running = true;
|
||||
applog(LOG_START, "linuxSmartie started");
|
||||
applog(LOG_START, "linuxSmartie starting");
|
||||
applog(LOG_DBG, "Compiled on %s %s with %s", __DATE__, __TIME__, C_STD);
|
||||
struct sensors_t *sensors = malloc(sizeof(*sensors)); // no actual point in mallocing and it is ever so sligtly slower to access heap vs stack, but its cool
|
||||
|
||||
/* see if another instance is up, quit if it is */
|
||||
if (get_instance_lock() < 0)
|
||||
return 1;
|
||||
|
||||
/* malloc memory for the struct */
|
||||
struct sensors_t *sensors = malloc(sizeof(*sensors)); // no actual point in mallocing and it is ever so sligtly slower to access heap vs stack, but its cool
|
||||
if (sensors == NULL) {
|
||||
applog(LOG_ERR, "can't allocate mem for the sensor struct. You don't got %lu bytes bro?", sizeof(struct sensors_t));
|
||||
free(sensors);
|
||||
return -1;
|
||||
return 2;
|
||||
}
|
||||
applog(LOG_INF, "sensor struct allocated, size is %lu bytes", sizeof(struct sensors_t));
|
||||
|
||||
@@ -196,6 +200,7 @@ int main(void) {
|
||||
/* control vars setup */
|
||||
pthread_mutex_init(&control.sensors_mtx, NULL);
|
||||
pthread_cond_init(&control.sensors_ready, NULL);
|
||||
control.g_running = true;
|
||||
|
||||
/* thread setup */
|
||||
pthread_t sensors_pthread;
|
||||
|
||||
Reference in New Issue
Block a user