aboutsummaryrefslogtreecommitdiffstats
path: root/pipe.c
blob: a4b44c238585656ec3fae38fa26ebec1e880bc17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}