Ejemplo n.º 1
0
Archivo: imore.cpp Proyecto: annp/ACE
static int
setup_unnamed_pipe (ACE_Process_Options &opt)
{
  // Create an unnamed pipe instance.
  ACE_Pipe pipe;

  // Check if the pipe is created successfully.
  if (pipe.open () == -1)
    ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "pipe.open"), -1);

  // Setting up pipe between parent and child process.  Use the pipe
  // as child process'es ACE_STDIN.  ACE_Process_Options will keep
  // copies (by dup) of fd's that we pass in.  Notice that we have to
  // specify child process to use ACE_STDOUT for output explicitly
  // because we'll close it down in the line after.  Child process
  // will use whatever we use to dup2 ACE_STDOUT as its stdout.
  opt.set_handles (pipe.read_handle (), ACE_STDOUT);

  // The previous keep a copy of original ACE_STDOUT fd, now we
  // can replace ACE_STDOUT of parent process to the pipe.
  ACE_OS::dup2 (pipe.write_handle (), ACE_STDOUT);

  // Don't forget to close the unused fd.
  pipe.close ();
  return 0;
}
Ejemplo n.º 2
0
  ACE_HANDLE Socket_Impl::
    get_handle_ ()
    {
      if (signal_pipe_.read_handle () == ACE_INVALID_HANDLE)
        {
          signal_pipe_.open ();
        }

      return signal_pipe_.read_handle ();
    }
Ejemplo n.º 3
0
int Handler::open(ACE_Reactor * r)
{
    if(-1 == the_pipe_.open(handles_))
    {
      return -1;
    }
    if(-1 == r->register_handler(this, ACE_Event_Handler::READ_MASK))
    {
      return -1;
    }
    return 0;
}
Ejemplo n.º 4
0
static void
open_pipe (ACE_Pipe &pipe,
           const char *name)
{
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("opening %C\n"), name));
    int result = pipe.open ();

    ACE_TEST_ASSERT (result != -1);
    result = pipe.read_handle () != ACE_INVALID_HANDLE
             && pipe.write_handle () != ACE_INVALID_HANDLE;
    ACE_TEST_ASSERT (result == 1);

    if (close_pipe)
        pipe.close ();
}