mirror of
https://github.com/mii443/qemu.git
synced 2025-08-31 03:19:27 +00:00
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>
This commit is contained in:
committed by
Michael Roth
parent
d9fcd2a1c8
commit
04b4e75f33
17
qemu-ga.c
17
qemu-ga.c
@ -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)
|
||||
|
Reference in New Issue
Block a user