{"id":7173,"date":"2022-12-20T19:35:43","date_gmt":"2022-12-20T22:35:43","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/error-man3\/"},"modified":"2022-12-20T19:35:43","modified_gmt":"2022-12-20T22:35:43","slug":"error-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/error-man3\/","title":{"rendered":"ERROR (man3)"},"content":{"rendered":"<h1 align=\"center\">ERROR<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">error, error_at_line, error_message_count, error_one_per_line, error_print_progname \u2212 glibc error reporting functions<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <error.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void error(int<\/b> <i>status<\/i><b>, int<\/b> <i>errnum<\/i><b>, const char *<\/b><i>format<\/i><b>, &#8230;);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void error_at_line(int<\/b> <i>status<\/i><b>, int<\/b> <i>errnum<\/i><b>, const char *<\/b><i>filename<\/i><b>, <br \/> unsigned int<\/b> <i>linenum<\/i><b>, const char *<\/b><i>format<\/i><b>, &#8230;);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>extern unsigned int<\/b> <i>error_message_count<\/i><b>;<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>extern int<\/b> <i>error_one_per_line<\/i><b>;<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>extern void (*<\/b><i>error_print_progname<\/i><b>) (void);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>error<\/b>() is a general error-reporting function. It flushes <i>stdout<\/i>, and then outputs to <i>stderr<\/i> the program name, a colon and a space, the message specified by the <b>printf<\/b>(3)-style format string <i>format<\/i>, and, if <i>errnum<\/i> is nonzero, a second colon and a space followed by the string given by <i>strerror(errnum)<\/i>. Any arguments required for <i>format<\/i> should follow <i>format<\/i> in the argument list. The output is terminated by a newline character.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The program name printed by <b>error<\/b>() is the value of the global variable <b>program_invocation_name<\/b>(3). <i>program_invocation_name<\/i> initially has the same value as <i>main<\/i>()\u2019s <i>argv[0]<\/i>. The value of this variable can be modified to change the output of <b>error<\/b>().<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If <i>status<\/i> has a nonzero value, then <b>error<\/b>() calls <b>exit<\/b>(3) to terminate the program using the given value as the exit status.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>error_at_line<\/b>() function is exactly the same as <b>error<\/b>(), except for the addition of the arguments <i>filename<\/i> and <i>linenum<\/i>. The output produced is as for <b>error<\/b>(), except that after the program name are written: a colon, the value of <i>filename<\/i>, a colon, and the value of <i>linenum<\/i>. The preprocessor values <b>__LINE__<\/b> and <b>__FILE__<\/b> may be useful when calling <b>error_at_line<\/b>(), but other values can also be used. For example, these arguments could refer to a location in an input file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the global variable <i>error_one_per_line<\/i> is set nonzero, a sequence of <b>error_at_line<\/b>() calls with the same value of <i>filename<\/i> and <i>linenum<\/i> will result in only one message (the first) being output.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The global variable <i>error_message_count<\/i> counts the number of messages that have been output by <b>error<\/b>() and <b>error_at_line<\/b>().<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the global variable <i>error_print_progname<\/i> is assigned the address of a function (i.e., is not NULL), then that function is called instead of prefixing the message with the program name and colon. The function should print a suitable string to <i>stderr<\/i>.<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"> <\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\">\n<p>\u00a0<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p align=\"center\"><img decoding=\"async\" src=\"grohtml-1620761.png\" alt=\"Image grohtml-1620761.png\"><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The internal <i>error_one_per_line<\/i> variable is accessed (without any form of synchronization, but since it\u2019s an <i>int<\/i> used once, it should be safe enough) and, if <i>error_one_per_line<\/i> 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 cancellation, so it can be interrupted only after one of the two variables is modified. After that, <b>error_at_line<\/b>() is very much like <b>error<\/b>().<\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These functions and variables are GNU extensions, and should not be used in programs intended to be portable.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>err<\/b>(3), <b>errno<\/b>(3), <b>exit<\/b>(3), <b>perror<\/b>(3), <b>program_invocation_name<\/b>(3), <b>strerror<\/b>(3)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  error, error_at_line, error_message_count, error_one_per_line, error_print_progname \u2212 glibc error reporting functions <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,2933,3007],"class_list":["post-7173","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-error","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7173"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7173\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}