/* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)perror.c 8.1 (Berkeley) 06/04/93"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include #include #include void perror(s) const char *s; { register struct iovec *v; struct iovec iov[4]; v = iov; if (s && *s) { v->iov_base = (char *)s; v->iov_len = strlen(s); v++; v->iov_base = ": "; v->iov_len = 2; v++; } v->iov_base = strerror(errno); v->iov_len = strlen(v->iov_base); v++; v->iov_base = "\n"; v->iov_len = 1; (void)writev(STDERR_FILENO, iov, (v - iov) + 1); }