File: perror.3

package info (click to toggle)
manpages-es 1.55-9
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 7,468 kB
  • ctags: 6
  • sloc: sh: 1,629; makefile: 64
file content (107 lines) | stat: -rw-r--r-- 3,945 bytes parent folder | download | duplicates (4)
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
105
106
107
.\" Copyright (c) 1994 Michael Haardt (michael@moria.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., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" 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 García <gerardo.aburruzaga@uca.es>
.\" Traducción revisada por Miguel Pérez Ibars <mpi79470@alu.um.es> el 4-abril-2005
.\"
.TH PERROR 3 "14 diciembre 2001" "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 DESCRIPCIÓN
La rutina
.B perror()
produce un mensaje que va a la salida estándar de errores,
describiendo el último error encontrado durante una llamada al sistema
o a ciertas funciones de biblioteca.
Primero (si
.I s
es distinto de NULL y
.RI * s
no es NUL) se imprime la cadena
.I s
pasada como argumento, seguida de un signo de dos puntos y un espacio en blanco.
Después se imprime el mensaje y un salto de línea.

Para ser de más utilidad, la cadena de caracteres pasada como
argumento debería incluir el nombre de la función que incurrió en el
error. El código 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 errónea.

Puede utilizarse la lista global de errores
.IR sys_errlist "[]",
indexada por
.IR errno,
para obtener el mensaje del error sin el salto de línea.
El número más 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 añadido aún 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 también hacen esto.
La función
.B perror()
sirve para traducir este código 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 podría muy bien cambiar incluso el valor de esta
variable, a pesar de haber acabado bien, por ejemplo porque
internamente empleara alguna otra función 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 "VÉASE TAMBIÉN"
.BR strerror (3)