4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
8 * Cherepanov Vitaliy <v.cherepanov@samsung.com>
10 * This library is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU Lesser General Public License as published by the
12 * Free Software Foundation; either version 2.1 of the License, or (at your option)
15 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
16 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library; if not, write to the Free Software Foundation, Inc., 51
22 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 * - Samsung RnD Institute Russia
31 #include <sys/types.h>
39 static inline int __redirect(int old, int new)
43 if (dup2(old, new) == -1) {
44 /* fail to print up there. there is no sdterr */
45 /* TODO inform about problem */
46 fprintf(stderr, "dup2 fail\n");
53 int __redirect_std(void)
56 char STDOUT[MAX_PATH_LENGTH];
57 snprintf(STDOUT,sizeof(STDOUT), "/tmp/da_preloaded_%d_%d.log", getppid(), getpid());
59 #define STDOUT "/dev/null"
63 int fd = open(STDOUT, O_WRONLY | O_CREAT | O_TRUNC, 0777);
65 if (__redirect(fd, 1) != 0 ||
66 __redirect(fd, 2) != 0) {
67 /* fail to print up there. there is no sdterr */
68 /* TODO inform about problem */
69 /* fprintf(sdterr, "duplicate fd fail\n"); */
75 /* TODO inform about problem */