1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

C++ wrapper of pipe2(2)

This commit is contained in:
Pavel Labath 2011-02-27 00:09:08 +01:00
parent 536f719c65
commit bcfc90accb
2 changed files with 14 additions and 0 deletions

View File

@ -32,3 +32,12 @@ std::string strerror_r(int errnum)
char buf[100]; char buf[100];
return strerror_r(errnum, buf, sizeof buf); return strerror_r(errnum, buf, sizeof buf);
} }
std::pair<int, int> pipe2(int flags)
{
int fd[2];
if(pipe2(fd, flags) == -1)
throw errno_error("pipe2");
else
return std::pair<int, int>(fd[0], fd[1]);
}

View File

@ -24,10 +24,15 @@
#ifndef CPPWRAP_HH #ifndef CPPWRAP_HH
#define CPPWRAP_HH #define CPPWRAP_HH
#include <unistd.h>
#include <cerrno>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <utility>
std::string strerror_r(int errnum); std::string strerror_r(int errnum);
std::pair<int, int> pipe2(int flags);
class errno_error: public std::runtime_error { class errno_error: public std::runtime_error {
typedef std::runtime_error Base; typedef std::runtime_error Base;