Copyright clean-up (part 1):
[AROS.git] / arch / all-hosted / bootstrap / log.c
blob3e0f51b4464900eaad564d245ce38bd34bc04142
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <fcntl.h>
7 #include <stdio.h> /* Needed for STDERR_FILENO on Windows */
8 #ifdef _WIN32
9 #include <io.h>
10 #else
11 #include <unistd.h>
12 #endif
14 #include "log.h"
16 int SetLog(const char *c)
19 * Redirect stderr on filedescriptor level.
20 * Redirecting on streams level does not work with Android's Bionic
22 int fd = open(c, O_WRONLY|O_CREAT|O_APPEND, 0644);
24 if (fd == -1)
25 return -1;
27 if (dup2(fd, STDERR_FILENO) == -1)
29 close(fd);
30 return -1;
33 return 0;