2013-05-10 Joel Brobecker <brobecker@adacore.com>

Tom Tromey  <tromey@redhat.com>

	* common/filestuff.c (mark_fd_no_cloexec, unmark_fd_no_cloexec):
	New functions.
	* common/filestuff.c (mark_fd_no_cloexec, unmark_fd_no_cloexec):
	Declare.
	* darwin-nat.c (darwin_pre_ptrace): Use mark_fd_no_cloexec.
	(darwin_ptrace_him): Use unmark_fd_no_cloexec.
	* inf-ttrace.c (do_cleanup_pfds): Use unmark_fd_no_cloexec.
	(inf_ttrace_prepare): Use mark_fd_no_cloexec.
This commit is contained in:
Tom Tromey
2013-05-10 17:01:00 +00:00
parent d3685d60d6
commit 21ff46861c
5 changed files with 67 additions and 0 deletions

View File

@@ -177,6 +177,33 @@ notice_open_fds (void)
fdwalk (do_mark_open_fd, NULL);
}
/* See filestuff.h. */
void
mark_fd_no_cloexec (int fd)
{
do_mark_open_fd (NULL, fd);
}
/* See filestuff.h. */
void
unmark_fd_no_cloexec (int fd)
{
int i, val;
for (i = 0; VEC_iterate (int, open_fds, i, val); ++i)
{
if (fd == val)
{
VEC_unordered_remove (int, open_fds, i);
return;
}
}
gdb_assert_not_reached (_("fd not found in open_fds"));
}
/* Helper function for close_most_fds that closes the file descriptor
if appropriate. */