Re:



>        The code seams to work correctly on Linux

No it doesn't, not for me at least. Hangs in the same way. You use a
(by default) buffered GIOChannel, and in that case
g_io_channel_read_chars() wants to read exactly the number of bytes
you ask for. So it blocks waiting for more to be written to the pipe
than just the "\nHello World\n".

Add this to your code and it works fine:

  g_io_channel_set_encoding(iochannel, NULL, NULL);
  g_io_channel_set_buffered(iochannel, FALSE);

(In general writing and reading the same pipe inside one thread means
there is a possibility of deadlock unless you are very careful and
know exactly how much is being written and that is is also read soon
enough. Change the hello() function to write a couple of kilobytes (on
Windows; on Linux some tens of kilobytes seem to be required because
the default pipe buffer is larger, or something) and watch the program
hang again.)

--tml


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]