gdb/common/filestuff.h - gdb

Macros defined

Source code

  1. /* Low-level file-handling.
  2.    Copyright (C) 2012-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef FILESTUFF_H
  15. #define FILESTUFF_H

  16. /* Note all the file descriptors which are open when this is called.
  17.    These file descriptors will not be closed by close_most_fds.  */

  18. extern void notice_open_fds (void);

  19. /* Mark a file descriptor as inheritable across an exec.  */

  20. extern void mark_fd_no_cloexec (int fd);

  21. /* Mark a file descriptor as no longer being inheritable across an
  22.    exec.  This is only meaningful when FD was previously passed to
  23.    mark_fd_no_cloexec.  */

  24. extern void unmark_fd_no_cloexec (int fd);

  25. /* Close all open file descriptors other than those marked by
  26.    'notice_open_fds', and stdin, stdout, and stderr.  Errors that
  27.    occur while closing are ignored.  */

  28. extern void close_most_fds (void);

  29. /* Like 'open', but ensures that the returned file descriptor has the
  30.    close-on-exec flag set.  */

  31. extern int gdb_open_cloexec (const char *filename, int flags,
  32.                              /* mode_t */ unsigned long mode);

  33. /* Like 'fopen', but ensures that the returned file descriptor has the
  34.    close-on-exec flag set.  */

  35. extern FILE *gdb_fopen_cloexec (const char *filename, const char *opentype);

  36. /* Like 'socketpair', but ensures that the returned file descriptors
  37.    have the close-on-exec flag set.  */

  38. extern int gdb_socketpair_cloexec (int namespace, int style, int protocol,
  39.                                    int filedes[2]);

  40. /* Like 'socket', but ensures that the returned file descriptor has
  41.    the close-on-exec flag set.  */

  42. extern int gdb_socket_cloexec (int namespace, int style, int protocol);

  43. /* Like 'pipe', but ensures that the returned file descriptors have
  44.    the close-on-exec flag set.  */

  45. extern int gdb_pipe_cloexec (int filedes[2]);

  46. #endif /* FILESTUFF_H */