aboutsummaryrefslogtreecommitdiff
path: root/lib/init/init_socket_send_request.c
blob: dd88856dddc137f69f7be860dbc191d5f58a2218 (plain)
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
/* 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;
}