title: GTKmm + pipe() not working
body: <p>I have this code:</p>
  
  <pre><code>#include &lt;gtkmm.h&gt;
  #include &lt;unistd.h&gt;
  
  
  void send_msg(Gtk::Entry* entry, int* fd);
  Glib::ustring* receive_msg(int* fd);
  bool handle_msg(Gtk::Label* lbl, int* fd);
  
  
  
  
  int main()
  {
      pid_t pid = fork();
  
      int fd[2];
      pipe(fd);
  
      Gtk::Main gtkmain;
      Gtk::Window* win;
      Glib::RefPtr&lt;Gtk::Builder&gt; builder;
  
      if (pid &gt; 0)
      {
          close(fd[1]);
  
          builder = Gtk::Builder::create_from_file("parent.glade");
          builder-&gt;get_widget("parentwin", win);
  
          Gtk::Label* lbl;
          builder-&gt;get_widget("label", lbl);
          sigc::slot&lt;bool&gt; timer = sigc::bind(sigc::ptr_fun(&amp;handle_msg), lbl, fd);
          Glib::signal_timeout().connect(timer, 1000);
      }
      else if (pid == 0)
      {
          close(fd[0]);
  
          builder = Gtk::Builder::create_from_file("child.glade");
          builder-&gt;get_widget("childwin", win);
  
          Gtk::Button* send;
          Gtk::Entry* txt;
          builder-&gt;get_widget("send", send);
          builder-&gt;get_widget("msg", txt);
          send-&gt;signal_clicked().connect(sigc::bind(sigc::ptr_fun(&amp;send_msg), txt, fd));
      }
  
      Gtk::Main::run(*win);
  
      return EXIT_SUCCESS;
  }
  
  
  
  
  
  
  
  void send_msg(Gtk::Entry* entry, int* fd)
  {
      Glib::ustring msg = entry-&gt;get_text();
      const char* c_msg = msg.c_str();
  
      int i = 0;
      char* c = new char(0);
  
      while (*c = c_msg[i++])
      {
          write(fd[1], c, 1);
      }
  }
  
  
  
  Glib::ustring* receive_msg(int* fd)
  {
      Glib::ustring* msg = new Glib::ustring;
      char* c = new char(0);
  
      do
      {
          read(fd[0], c, 1);
          msg-&gt;append(c);
      } while (*c);
  
      return msg;
  }
  
  
  
  bool handle_msg(Gtk::Label* lbl, int* fd)
  {
      Glib::ustring* msg;
      msg = receive_msg(fd);
      lbl-&gt;set_text(*msg);
      // delete msg;
      return true;
  }
  </code></pre>
  
  <p>and it's purpose is this:
  The whole program works similar to a chat program, just not intended for that. The <code>child</code> process brings up a window with an Entry and a Button in it, to send the contents of Entry using a low level code that uses <code>write()</code> function, and the parent brings up a window with just a Label in it to display the data received at low level with <code>read()</code>.</p>
  
  <p>The exact functionality that I'm after I could achieve without gtkmm, but even when I write the <code>read()</code> and <code>write()</code> codes right before gtkmm parts under <code>close()</code> to test the functionality of read/write as a test to bypass function calls, it still won't work.</p>
  
  <p>The only possibility I can think of, is an incompatibility between <code>unistd.h</code> and <code>gtkmm.h</code>.</p>
  
  <p>(and also I know the code is a bunch of dirt in writing, to some extent, but its a practice, forget that! ;-) )</p>
  
  <p>Thanks so much for your helps :-)</p>