date and time created 90/06/23 16:23:27 by bostic
[unix-history] / usr / src / lib / libc / stdio / perror.c
CommitLineData
bb0cfa24 1/*
74e67efa
KB
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
269a7923 5 * %sccs.include.redist.c%
bb0cfa24
DF
6 */
7
2ce81398 8#if defined(LIBC_SCCS) && !defined(lint)
269a7923 9static char sccsid[] = "@(#)perror.c 5.9 (Berkeley) %G%";
74e67efa 10#endif /* LIBC_SCCS and not lint */
bb0cfa24 11
df5b5637
SL
12#include <sys/types.h>
13#include <sys/uio.h>
716337de 14
716337de 15perror(s)
df5b5637 16 char *s;
716337de 17{
8156daf7
KB
18 extern int errno;
19 register struct iovec *v;
df5b5637 20 struct iovec iov[4];
8156daf7 21 char *strerror();
716337de 22
8156daf7 23 v = iov;
df5b5637
SL
24 if (s && *s) {
25 v->iov_base = s;
26 v->iov_len = strlen(s);
27 v++;
28 v->iov_base = ": ";
29 v->iov_len = 2;
30 v++;
716337de 31 }
8156daf7 32 v->iov_base = strerror(errno);
df5b5637
SL
33 v->iov_len = strlen(v->iov_base);
34 v++;
35 v->iov_base = "\n";
36 v->iov_len = 1;
74e67efa 37 (void)writev(2, iov, (v - iov) + 1);
716337de 38}