Error checking on pthread_create

This commit is contained in:
Casey 2023-11-18 14:14:01 +03:00
parent ea1dc41d61
commit fed1c0a3ca
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
2 changed files with 8 additions and 6 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
cbt
cbt_impl.c
state
add_impl.py
add-impl.py

12
cbt.h
View File

@ -147,7 +147,6 @@ const char *cbt_log__colors[CBT_LOG_ALL + 1] = {
const char *cbt_log__text[CBT_LOG_ALL + 1] = {"FATAL", "ERROR", "WARN ",
"INFO ", "DEBUG", "TRACE"};
void *cbt__line_processor(void *);
void cbt__init(int argc, char **argv, const char *source_file) {
@ -155,8 +154,7 @@ void cbt__init(int argc, char **argv, const char *source_file) {
cbt_running = true;
(void)argc;
cbt_log(CBT_LOG_INFO, "Running CBT build %s %s from %s", __DATE__, __TIME__,
__FILE__);
cbt_log(CBT_LOG_INFO, "Running CBT build %s %s from %s", __DATE__, __TIME__, __FILE__);
if (!cbt_cc)
cbt_cc = getenv("CC");
@ -171,8 +169,12 @@ void cbt__init(int argc, char **argv, const char *source_file) {
calloc(cbt__default_procgroup.cap, sizeof(struct cbt_proc));
cbt_log(CBT_LOG_DEBUG, "Starting line processor thread");
// TODO: error checking
pthread_create(&_cbt__autoproc_thread, NULL, cbt__line_processor, NULL);
int err;
if ((err = pthread_create(&_cbt__autoproc_thread, NULL, cbt__line_processor, NULL)) != 0) {
cbt_log(CBT_LOG_ERROR, "pthread_create() failed for line processor: %d", err);
exit(1);
}
if (cbt_needs_recompilation(source_file, argv[0])) {
cbt_log(CBT_LOG_INFO, "Recompiling...");