Export g_win32_input_stream_new_from_fd and g_win32_output_stream_new_from_fd
Hi all,
I was wondering if there would be any objections to me opening a MR that would arrange for the functions g_win32_input_stream_new_from_fd
and g_win32_output_stream_new_from_fd
to be exported and become part of the public GIO API.
These methods are useful, for example in my case where I use g_spawn_async_with_pipes
in some cross-platform code to launch a process. Since I want to use the GInput/GOutputStream API to parse and process the I/O from the file descriptor, it is currently rather hard to use GWin32InputStream and GWin32OutputStream for this purpose. The constructors for these classes require a Win32 HANDLE
pointer instead of a file descriptor.
Now it is possible to obtain such a HANDLE
from a file descriptor using the _get_osfhandle
function from the Windows API, but its documentation clearly states that one cannot close the handle, and instead must close the file descriptor instead: this means that I have to ensure that the handles cannot be closed when the object is destroyed, and I need to manually call close
on the file descriptors at the right moment, which leads to a lot of ugly #ifdef G_OS_WIN32
blocks in my code. I can confirm that when not handling this situation manually, a lot of undefined behaviour tends to occur...
Exporting these two methods would make things a lot more elegant.
I will gladly open an MR to incorporate the necessary changes.