File: perror.3

package info (click to toggle)
manpages-es 1.24a-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,256 kB
  • ctags: 7
  • sloc: makefile: 66; sh: 62
file content (104 lines) | stat: -rw-r--r-- 3,815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
.\" Copyright (c) 1994 Michael Haardt
.\" (u31b3hs@pool.informatik.rwth-aachen.de), Sat Jun  4 20:38:26 MET
.\" DST 1994 
.\" Copyright (c) 1995 Michael Haardt
.\" (michael@cantor.informatik.rwth-aachen.de), Thu Mar 16 18:46:23
.\" MET 1995 
.\" Copyright (c) 1996 Andries Brouwer (aeb@cwi.nl), Sat Jan 13 00:16:41 MET 1996
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, write to the Free
.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
.\" USA.
.\"
.\" Sat Jan 13 00:16:41 MET 1996, aeb: merged in some text contributed
.\" by Melvin Smith (msmith@falcon.mercer.peachnet.edu) and various
.\" other changes.
.\" Modified Fri May 16 23:41:15 1996 by Martin Schulze (joey@infodrom.north.de)
.\"
.\" Translated into Spanish Thu Mar  5 09:38:23 CET 1998 by Gerrado
.\" Aburruzaga Garca <gerardo.aburruzaga@uca.es>
.\"
.TH PERROR 3 "5 Marzo 1998" "Linux" "Funciones de Biblioteca"
.SH NOMBRE
perror \- muestra un mensaje correspondiente a un error del sistema
.SH SINOPSIS
.B #include <stdio.h>
.sp
.BI "void perror(const char " *s );
.sp
.B #include <errno.h>
.sp
.BI "const char *" sys_errlist [];
.br
.BI "int " sys_nerr ;
.SH DESCRIPCIN
La rutina
.B perror()
produce un mensaje que va a la salida estndar de errores,
describiendo el ltimo error encontrado durante una llamada al sistema
o a ciertas funciones de biblioteca. La cadena de caracteres
.I s
que se  pasa como argumento, se muestra primero, luego un signo de dos
puntos y un espacio en blanco; por ltimo, el mensaje y un salto de
lnea. Para ser de ms utilidad, la cadena de caracteres pasada como
argumento debera incluir el nombre de la funcin que incurri en el
error. El cdigo del error se toma de la variable externa
.IR errno ,
que toma un valor cuando ocurre un error pero no es puesta a cero
en una llamada no errnea.

Puede utilizarse la lista global de errores
.IR sys_errlist "[]",
indexada por
.IR errno,
para obtener el mensaje del error sin el salto de lnea.
El nmero ms alto de mensaje proporcionado en la tabla es
.IR sys_nerr " \-1."
Tenga cuidado cuando acceda directamente a esta lista porque puede que
no se hayan aadido an nuevos valores de error a
.IR sys_errlist "[]."

Cuando una llamada al sistema falla, normalmente devuelve \-1 y pone
en la
variable
.I errno
un valor que describe qu fue mal. (Estos valores pueden encontrarse en
.IR "<errno.h>" .)
Muchas funciones de biblioteca tambin hacen esto.
La funcin
.B perror()
sirve para traducir este cdigo de error a una forma que los humanos
puedan entender.
Observe que
.I errno
tiene un valor sin definir tras una llamada exitosa:
esta llamada podra muy bien cambiar incluso el valor de esta
variable, a pesar de haber acabado bien, por ejemplo porque
internamente empleara alguna otra funcin de biblioteca que hubiera fallado.
As, si una llamada fallida no es seguida inmediatamente por una
llamada a
.BR perror ,
el valor de
.I errno
debe guardarse.

.SH "CONFORME A"
C ANSI, BSD 4.3, POSIX, X/OPEN
.SH "VASE TAMBIN"
.BR strerror (3)