error(3) Library Functions Manual error(3) error, error_at_line, error_message_count, error_one_per_line, error_print_progname - glibc C (libc, -lc) #include void error(int status, int errnum, const char *format, ...); void error_at_line(int status, int errnum, const char *filename, unsigned int linenum, const char *format, ...); extern unsigned int error_message_count; extern int error_one_per_line; extern void (*error_print_progname)(void); error() . stdout, stderr , , , , format printf(3) , errnum , , , strerror(errnum). , format, format. . , error(), program_invocation_name(3). , program_invocation_name argv[0] main(). error(). If status has a nonzero value, then error() calls exit(3) to terminate the program using the given value as the exit status; otherwise it returns after printing the error message. error_at_line() error(), filename linenum. error(), : , filename, linenum. error_at_line() __LINE__ __FILE__, . , . error_one_per_line , error_at_line() filename linenum (). error_message_count , error() error_at_line(). error_print_progname (.., NULL), . stderr. attributes(7). +----------------------------+----------------------------------------------------------+----------------------------------+ | | | | +----------------------------+----------------------------------------------------------+----------------------------------+ |error() | | MT-Safe locale | +----------------------------+----------------------------------------------------------+----------------------------------+ |error_at_line() | | MT-Unsafe race: error_at_line/ | | | | error_one_per_line locale | +----------------------------+----------------------------------------------------------+----------------------------------+ The internal error_one_per_line variable is accessed (without any form of synchronization, but since it's an int used once, it should be safe enough) and, if error_one_per_line is set nonzero, the internal static variables (not exposed to users) used to hold the last printed filename and line number are accessed and modified without synchronization; the update is not atomic and it occurs before disabling cancelation, so it can be interrupted only after one of the two variables is modified. After that, error_at_line() is very much like error(). GNU. err(3), errno(3), exit(3), perror(3), program_invocation_name(3), strerror(3) () Azamat Hackimov , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 2 2024 . error(3)