Hello!
I am trying to use notify a main gtk thread ( from a separate thread) that some even occurred using pipes. I get the following warning when I am trying to setup pipes. What is a good workaround?
when I can this g_io_channel_win32_new_fd, I see this warning, and thus pipe isn't created at all :(
GLib-WARNING **: giowin32.c:1564: 3 isn't a C library file descriptor
int fds[2];
GIOChannel* gioChannels[2];
HANDLE rdPipe, wrPipe;
SECURITY_ATTRIBUTES saAttr;
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
if (CreatePipe(&rdPipe, &wrPipe, NULL, 1024))
{
fds[0] =_open_osfhandle((gssize)rdPipe, O_RDONLY);
fds[1] = _open_osfhandle((long)wrPipe,_O_APPEND);
gioChannels[0] =g_io_channel_win32_new_fd(fds[0] );
gioChannels[1] =g_io_channel_win32_new_fd(fds[0] );
g_io_add_watch( gioChannels[1],(GIOCondition) (G_IO_IN | G_IO_HUP),
(GIOFunc)SomeCallaback,(gpointer)this );
}
The goal is to notify main application that something occurred in thread thread. In my case, I can't use gtk in multi-threaded way (calling functions of main thread from spawned one), so I am trying to do it via pipes.
I also saw that it could be a visual studio issue in this thread
Any suggestions?