source: trunk/minix/lib/stdio/perror.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 627 bytes
Line 
1/*
2 * perror.c - print an error message on the standard error output
3 */
4/* $Header: /cvsup/minix/src/lib/stdio/perror.c,v 1.1.1.1 2005/04/21 14:56:36 beng Exp $ */
5
6#if defined(_POSIX_SOURCE)
7#include <sys/types.h>
8#endif
9#include <stdio.h>
10#include <errno.h>
11#include <stdio.h>
12#include <string.h>
13#include "loc_incl.h"
14
15ssize_t _write(int d, const char *buf, size_t nbytes);
16
17void
18perror(const char *s)
19{
20 char *p;
21 int fd;
22
23 p = strerror(errno);
24 fd = fileno(stderr);
25 fflush(stdout);
26 fflush(stderr);
27 if (s && *s) {
28 _write(fd, s, strlen(s));
29 _write(fd, ": ", 2);
30 }
31 _write(fd, p, strlen(p));
32 _write(fd, "\n", 1);
33}
Note: See TracBrowser for help on using the repository browser.