aboutsummaryrefslogtreecommitdiffstats
path: root/pipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'pipe.c')
-rw-r--r--pipe.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/pipe.c b/pipe.c
new file mode 100644
index 0000000..a4b44c2
--- /dev/null
+++ b/pipe.c
@@ -0,0 +1,32 @@
+/* See LICENSE file for copyright and license details. */
+#include "internal.h"
+
+
+int
+liberror_pipe(int fds[2])
+{
+ const char *desc;
+ if (!fds) {
+ desc = "Output parameter is NULL";
+ goto error;
+ }
+ if (!pipe(fds))
+ return 0;
+ switch (errno) {
+ case EFAULT:
+ desc = "Output parameter is an invalid pointer";
+ break;
+ case EMFILE:
+ desc = "The process have too many file descriptors open";
+ break;
+ case ENFILE:
+ desc = "The system have too many file descriptors open";
+ break;
+ default:
+ desc = "";
+ break;
+ }
+error:
+ liberror_set_error_errno(desc, "pipe", errno);
+ return -1;
+}