Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a helper to avoid duplicating code for socketpairs creation
Baptiste Daroussin committed 6 years ago
commit 260820b619f2ae19d819fcdd6c75d322b52b702a
parent d22e5a8
2 files changed +14 -0
modified libpkg/private/utils.h
@@ -99,5 +99,6 @@ int *text_diff(char *a, char *b);
int merge_3way(char *pivot, char *v1, char *v2, UT_string *out);
bool string_end_with(const char *path, const char *str);
bool mkdirat_p(int fd, const char *path);
+
int get_socketpair(int *);

#endif
modified libpkg/utils.c
@@ -28,6 +28,7 @@

#include <pkg_config.h>

+
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <stdio.h>
@@ -818,3 +819,15 @@ pkg_namecmp(struct pkg *a, struct pkg *b)

	return (strcmp(a->name, b->name));
}
+

+
int
+
get_socketpair(int *pipe)
+
{
+
	int st = SOCK_DGRAM;
+

+
#ifdef HAVE_DECL_SOCK_SEQPACKET
+
	st = SOCK_SEQPACKET;
+
#endif
+

+
	return (socketpair(AF_UNIX, st, 0, pipe));
+
}