Closed havardAasen closed 2 months ago
'pthread_*' functions do not set errno variable.
The error handling is incorrect, reading manuals (for example https://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html) there where no mentioning settings errno. But there is macro which sets manually:
// in https://man7.org/linux/man-pages/man3/pthread_setschedparam.3.html example
#define handle_error_en(en, msg) \
do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
Right, my bad. I'll update the patch, thanks.
According to man pages, calls to 'pthread_*' can return 'a nonzero value'. This means it can be both negative and positive, we have to check for both.
This commit includes the diff supplied in #2656 and also fixes the same mistake in other files. Fixes: #2656