GDB (API)
|
00001 /* Low-level file-handling. 00002 Copyright (C) 2012, 2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #ifndef FILESTUFF_H 00020 #define FILESTUFF_H 00021 00022 /* Note all the file descriptors which are open when this is called. 00023 These file descriptors will not be closed by close_most_fds. */ 00024 00025 extern void notice_open_fds (void); 00026 00027 /* Mark a file descriptor as inheritable across an exec. */ 00028 00029 extern void mark_fd_no_cloexec (int fd); 00030 00031 /* Mark a file descriptor as no longer being inheritable across an 00032 exec. This is only meaningful when FD was previously passed to 00033 mark_fd_no_cloexec. */ 00034 00035 extern void unmark_fd_no_cloexec (int fd); 00036 00037 /* Close all open file descriptors other than those marked by 00038 'notice_open_fds', and stdin, stdout, and stderr. Errors that 00039 occur while closing are ignored. */ 00040 00041 extern void close_most_fds (void); 00042 00043 /* Like 'open', but ensures that the returned file descriptor has the 00044 close-on-exec flag set. */ 00045 00046 extern int gdb_open_cloexec (const char *filename, int flags, 00047 /* mode_t */ unsigned long mode); 00048 00049 /* Like 'fopen', but ensures that the returned file descriptor has the 00050 close-on-exec flag set. */ 00051 00052 extern FILE *gdb_fopen_cloexec (const char *filename, const char *opentype); 00053 00054 /* Like 'socketpair', but ensures that the returned file descriptors 00055 have the close-on-exec flag set. */ 00056 00057 extern int gdb_socketpair_cloexec (int namespace, int style, int protocol, 00058 int filedes[2]); 00059 00060 /* Like 'socket', but ensures that the returned file descriptor has 00061 the close-on-exec flag set. */ 00062 00063 extern int gdb_socket_cloexec (int namespace, int style, int protocol); 00064 00065 /* Like 'pipe', but ensures that the returned file descriptors have 00066 the close-on-exec flag set. */ 00067 00068 extern int gdb_pipe_cloexec (int filedes[2]); 00069 00070 #endif /* FILESTUFF_H */