diff options
author | Luiz Capitulino <lcapitulino@redhat.com> | 2012-05-10 16:50:41 -0300 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2012-05-15 09:15:16 -0500 |
commit | 04b4e75f33ae0775d70b8e33080f46d66275cdcc (patch) | |
tree | d6ec33bf787cc012c9f85c6cdd07ac83f1ad6c44 /qemu-ga.c | |
parent | d9fcd2a1c825791cec9b21e634013b728422972f (diff) |
qemu-ga: make reopen_fd_to_null() public
The next commit wants to use it.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qemu-ga.c')
-rw-r--r-- | qemu-ga.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -140,6 +140,23 @@ static gboolean register_signal_handlers(void) return true; } + +/* TODO: use this in place of all post-fork() fclose(std*) callers */ +void reopen_fd_to_null(int fd) +{ + int nullfd; + + nullfd = open("/dev/null", O_RDWR); + if (nullfd < 0) { + return; + } + + dup2(nullfd, fd); + + if (nullfd != fd) { + close(nullfd); + } +} #endif static void usage(const char *cmd) |