aboutsummaryrefslogtreecommitdiff
path: root/lib/init/init_socket_send_request.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2019-03-15 11:23:40 +0100
committerDavid Oberhollenzer <goliath@infraroot.at>2019-03-18 14:15:58 +0100
commitc78bbd2f731ae44c7d2588b9bb3d19005f192fc6 (patch)
treef71e53964f09eba1a6f7c98cccdf21c78ff19119 /lib/init/init_socket_send_request.c
parentc544fcc7a30d9a934b0f8d098e000259e8b9ed62 (diff)
Add helpers for initd socket
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'lib/init/init_socket_send_request.c')
-rw-r--r--lib/init/init_socket_send_request.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/init/init_socket_send_request.c b/lib/init/init_socket_send_request.c
new file mode 100644
index 0000000..dd88856
--- /dev/null
+++ b/lib/init/init_socket_send_request.c
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: ISC */
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "initsock.h"
+
+int init_socket_send_request(int fd, E_INIT_REQUEST rq)
+{
+ init_request_t request;
+ ssize_t ret;
+
+ memset(&request, 0, sizeof(request));
+ request.rq = rq;
+
+retry:
+ ret = write(fd, &request, sizeof(request));
+
+ if (ret < 0) {
+ if (errno == EINTR)
+ goto retry;
+ perror(INIT_SOCK_PATH);
+ return -1;
+ }
+
+ return 0;
+}