]> git.lizzy.rs Git - plan9front.git/blob - sys/man/2/perror
merge
[plan9front.git] / sys / man / 2 / perror
1 .TH PERROR 2
2 .SH NAME
3 perror, syslog, sysfatal \- system error messages
4 .SH SYNOPSIS
5 .B #include <u.h>
6 .br
7 .B #include <libc.h>
8 .PP
9 .B
10 void perror(char *s)
11 .PP
12 .B
13 void syslog(int cons, char *logname, char *fmt, ...)
14 .PP
15 .B
16 void sysfatal(char *fmt, ...)
17 .SH DESCRIPTION
18 .I Perror
19 produces a short error message
20 on the standard error file
21 describing the last error encountered during a call
22 to the system.
23 First the argument string
24 .I s
25 is printed, then a colon, then the message and a newline.
26 If
27 .I s
28 is nil, only the error message and newline are printed.
29 .PP
30 .I Syslog
31 logs messages in the file named by
32 .I logname
33 in the directory
34 .BR /sys/log ;
35 the file must already exist and should be append-only.
36 .I Logname
37 must contain no slashes.
38 The message is a line with several fields:
39 the name of the machine writing the message;
40 the date and time;
41 the message specified by the
42 .IR print (2)
43 format
44 .I fmt
45 and any following arguments;
46 and a final newline.
47 If
48 .I cons
49 is set or the log file cannot be opened, the message is also printed
50 on the system console.
51 .I Syslog
52 can be used safely in multi-threaded programs.
53 .PP
54 .I Sysfatal
55 prints to standard error the name of the running program,
56 a colon and a space, 
57 the message described by the
58 .IR print (2)
59 format string
60 .I fmt
61 and subsequent arguments, and a newline.
62 It then calls
63 .IR exits (2)
64 with the formatted message as argument.
65 The program's name is the value of
66 .BR argv0 ,
67 which will be set if the program uses the
68 .IR arg (2)
69 interface to process its arguments.
70 If
71 .B argv0
72 is null, it is ignored and the following colon and space are suppressed.
73 .SH SOURCE
74 .B /sys/src/libc/port/perror.c
75 .br
76 .B /sys/src/libc/9sys/syslog.c
77 .br
78 .B /sys/src/libc/9sys/sysfatal.c
79 .SH "SEE ALSO"
80 .IR intro (2),
81 .IR errstr (2),
82 the
83 .B %r
84 format in
85 .IR print (2)
86 .SH BUGS
87 .I Perror
88 is a holdover; the
89 .B %r
90 format in
91 .IR print (2)
92 is preferred.