ONPOSIX  2.0
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Pipe.cpp
Go to the documentation of this file.
1 /*
2  * Pipe.cpp
3  *
4  * Created on: 05/set/2012
5  * Author: cloud
6  */
7 
8 #include <stdexcept>
9 #include <unistd.h>
10 
11 #include "Pipe.hpp"
12 #include "Logger.hpp"
13 
14 namespace onposix {
15 
16 /**
17  * \brief Constructor for the pipe
18  *
19  * @exception runtime_error in case of error
20  */
21 Pipe::Pipe(): read_(0), write_(0)
22 {
23  int fd[2];
24  if (pipe(fd) != 0) {
25  ERROR("Opening pipe");
26  throw std::runtime_error ("Open pipe error");
27  }
28  read_ = new PosixDescriptor(fd[0]);
29  write_ = new PosixDescriptor(fd[1]);
30 }
31 
32 
33 } /* onposix */