11974Swnj /* 235303Sbostic * Copyright (c) 1988 Regents of the University of California. 335303Sbostic * All rights reserved. 435303Sbostic * 535303Sbostic * Redistribution and use in source and binary forms are permitted 635303Sbostic * provided that the above copyright notice and this paragraph are 735303Sbostic * duplicated in all such forms and that any documentation, 835303Sbostic * advertising materials, and other materials related to such 935303Sbostic * distribution and use acknowledge that the software was developed 1035303Sbostic * by the University of California, Berkeley. The name of the 1135303Sbostic * University may not be used to endorse or promote products derived 1235303Sbostic * from this software without specific prior written permission. 1335303Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1435303Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1535303Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1621351Sdist */ 1721351Sdist 1826574Sdonn #if defined(LIBC_SCCS) && !defined(lint) 19*37341Sbostic static char sccsid[] = "@(#)perror.c 5.8 (Berkeley) 04/09/89"; 2035303Sbostic #endif /* LIBC_SCCS and not lint */ 2121351Sdist 2213488Ssam #include <sys/types.h> 2313488Ssam #include <sys/uio.h> 241974Swnj 251974Swnj perror(s) 2613488Ssam char *s; 271974Swnj { 28*37341Sbostic extern int errno; 29*37341Sbostic register struct iovec *v; 3013488Ssam struct iovec iov[4]; 31*37341Sbostic char *strerror(); 321974Swnj 33*37341Sbostic v = iov; 3413488Ssam if (s && *s) { 3513488Ssam v->iov_base = s; 3613488Ssam v->iov_len = strlen(s); 3713488Ssam v++; 3813488Ssam v->iov_base = ": "; 3913488Ssam v->iov_len = 2; 4013488Ssam v++; 411974Swnj } 42*37341Sbostic v->iov_base = strerror(errno); 4313488Ssam v->iov_len = strlen(v->iov_base); 4413488Ssam v++; 4513488Ssam v->iov_base = "\n"; 4613488Ssam v->iov_len = 1; 4735303Sbostic (void)writev(2, iov, (v - iov) + 1); 481974Swnj } 49