4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8 * Jaewon Lim <jaewon81.lim@samsung.com>
9 * Woojin Jung <woojin2.jung@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
12 * This library is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation; either version 2.1 of the License, or (at your option)
17 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this library; if not, write to the Free Software Foundation, Inc., 51
24 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <stdlib.h> // for malloc
32 #include <string.h> // for memcpy
33 #include <errno.h> // for errno
38 int daemon_close_allv(const int except_fds[])
40 static int (*daemon_close_allvp)(const int except_fds[]);
41 int i, saved_errno, ret;
44 GET_REAL_FUNCP(daemon_close_allv, LIBDAEMON, daemon_close_allvp);
50 if(except_fds[i] == -1)
54 // allocate memory for new except fds
55 fds = (int*)malloc((i + 2) * sizeof(int));
61 memcpy(fds, except_fds, i * sizeof(int));
62 fds[i] = gTraceInfo.socket.daemonSock;
71 // call original function
74 ret = daemon_close_allvp(fds);
78 ret = daemon_close_allvp(except_fds);