diff options
author | Mattias Andrée <maandree@kth.se> | 2019-04-12 21:12:31 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-04-12 21:13:37 +0200 |
commit | bafb07a1644896d56ad4b8effaeaae601c5a275b (patch) | |
tree | ef4e38f529ba2f0cadc73ad88493a1cca206fe7b /pipe.c | |
download | liberror-libc-bafb07a1644896d56ad4b8effaeaae601c5a275b.tar.gz liberror-libc-bafb07a1644896d56ad4b8effaeaae601c5a275b.tar.bz2 liberror-libc-bafb07a1644896d56ad4b8effaeaae601c5a275b.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'pipe.c')
-rw-r--r-- | pipe.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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; +} |