fix: check pthread_create return code

This commit is contained in:
2026-05-16 18:29:38 +02:00
parent fcb2baf84a
commit 61c88aae2a
+32 -10
View File
@@ -108,8 +108,13 @@ static void start_video_background_read(VideoCapture *video_capture,
process_args->context = context; process_args->context = context;
process_args->input_index = input_index; process_args->input_index = input_index;
process_args->trace_fps = trace_fps; process_args->trace_fps = trace_fps;
pthread_create(&thread, NULL, video_background_read, (void *)process_args); if (pthread_create(&thread, NULL, video_background_read,
pthread_detach(thread); (void *)process_args) == 0) {
pthread_detach(thread);
} else {
log_error("background video acquisition failed to start");
free(process_args);
}
} }
static void * static void *
@@ -147,8 +152,12 @@ static void start_video_captures() {
} }
} }
if (init_params.video_reconnect) { if (init_params.video_reconnect) {
pthread_create(&thread, NULL, background_reconnect_video_captures, NULL); if (pthread_create(&thread, NULL, background_reconnect_video_captures,
pthread_detach(thread); NULL) == 0) {
pthread_detach(thread);
} else {
log_info("background video capture reconnect failed to start");
}
} }
} }
@@ -198,8 +207,13 @@ static void start_state_background_write() {
process_args->context = &context; process_args->context = &context;
process_args->state_config = project.state_config; process_args->state_config = project.state_config;
process_args->midi = &midi; process_args->midi = &midi;
pthread_create(&thread, NULL, state_background_write, process_args); if (pthread_create(&thread, NULL, state_background_write, process_args) ==
pthread_detach(thread); 0) {
pthread_detach(thread);
} else {
log_error("background writing failed to start");
free(process_args);
}
} }
static void start_midi_background_listen() { static void start_midi_background_listen() {
@@ -210,8 +224,13 @@ static void start_midi_background_listen() {
process_args->device = &midi; process_args->device = &midi;
process_args->context = &context; process_args->context = &context;
process_args->event_callback = midi_callback; process_args->event_callback = midi_callback;
pthread_create(&thread, NULL, midi_background_listen, process_args); if (pthread_create(&thread, NULL, midi_background_listen, process_args) ==
pthread_detach(thread); 0) {
pthread_detach(thread);
} else {
log_error("background midi acquisition failed to start");
free(process_args);
}
} }
static void *background_reconnect_midi(__attribute__((unused)) void *args) { static void *background_reconnect_midi(__attribute__((unused)) void *args) {
@@ -239,8 +258,11 @@ static void init_midi() {
} }
if (init_params.midi_reconnect) { if (init_params.midi_reconnect) {
pthread_create(&thread, NULL, background_reconnect_midi, NULL); if (pthread_create(&thread, NULL, background_reconnect_midi, NULL) == 0) {
pthread_detach(thread); pthread_detach(thread);
} else {
log_error("background midi reconnect failed to start");
}
} }
} }