mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
gio: add GUnixFDList on win32
FDs are not specific to Unix. win32 has APIs to map CRT fd to/from HANDLE. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
5eaa13f573
commit
5efb84f24a
@ -169,6 +169,7 @@
|
||||
#include <gio/gtlsserverconnection.h>
|
||||
#include <gio/gunixconnection.h>
|
||||
#include <gio/gunixcredentialsmessage.h>
|
||||
#include <gio/gunixfdlist.h>
|
||||
#include <gio/gunixsocketaddress.h>
|
||||
#include <gio/gvfs.h>
|
||||
#include <gio/gvolume.h>
|
||||
|
@ -26,9 +26,11 @@
|
||||
* the %G_SOCKET_FAMILY_UNIX family by using g_socket_send_message()
|
||||
* and received using g_socket_receive_message().
|
||||
*
|
||||
* Note that `<gio/gunixfdlist.h>` belongs to the UNIX-specific GIO
|
||||
* interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
|
||||
* file when using it.
|
||||
* Before 2.74, `<gio/gunixfdlist.h>` belonged to the UNIX-specific GIO
|
||||
* interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file when
|
||||
* using it.
|
||||
*
|
||||
* Since 2.74, the API is available for Windows.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -40,7 +42,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@ -48,6 +49,12 @@
|
||||
#include "gunixfdlist.h"
|
||||
#include "gnetworking.h"
|
||||
#include "gioerror.h"
|
||||
#include "glib/glib-private.h"
|
||||
#include "glib/gstdio.h"
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
struct _GUnixFDListPrivate
|
||||
{
|
||||
@ -70,7 +77,7 @@ g_unix_fd_list_finalize (GObject *object)
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < list->priv->nfd; i++)
|
||||
close (list->priv->fds[i]);
|
||||
g_close (list->priv->fds[i], NULL);
|
||||
g_free (list->priv->fds);
|
||||
|
||||
G_OBJECT_CLASS (g_unix_fd_list_parent_class)
|
||||
@ -90,7 +97,9 @@ dup_close_on_exec_fd (gint fd,
|
||||
GError **error)
|
||||
{
|
||||
gint new_fd;
|
||||
#ifndef G_OS_WIN32
|
||||
gint s;
|
||||
#endif
|
||||
|
||||
#ifdef F_DUPFD_CLOEXEC
|
||||
do
|
||||
@ -118,6 +127,9 @@ dup_close_on_exec_fd (gint fd,
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
new_fd = GLIB_PRIVATE_CALL (g_win32_reopen_noninherited) (new_fd, 0, error);
|
||||
#else
|
||||
do
|
||||
{
|
||||
s = fcntl (new_fd, F_GETFD);
|
||||
@ -134,10 +146,11 @@ dup_close_on_exec_fd (gint fd,
|
||||
g_set_error (error, G_IO_ERROR,
|
||||
g_io_error_from_errno (saved_errno),
|
||||
"fcntl: %s", g_strerror (saved_errno));
|
||||
close (new_fd);
|
||||
g_close (new_fd, NULL);
|
||||
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return new_fd;
|
||||
}
|
||||
|
@ -354,7 +354,6 @@ if host_system != 'windows'
|
||||
unix_sources = files(
|
||||
'gfiledescriptorbased.c',
|
||||
'giounix-private.c',
|
||||
'gunixfdlist.c',
|
||||
'gunixfdmessage.c',
|
||||
'gunixmount.c',
|
||||
'gunixmounts.c',
|
||||
@ -574,6 +573,7 @@ gio_sources = files(
|
||||
'gdtlsserverconnection.c',
|
||||
'gunionvolumemonitor.c',
|
||||
'gunixconnection.c',
|
||||
'gunixfdlist.c',
|
||||
'gunixcredentialsmessage.c',
|
||||
'gunixsocketaddress.c',
|
||||
'gvfs.c',
|
||||
|
Loading…
Reference in New Issue
Block a user