Kea: interprocess_util.cc Source File

| Kea 3.2.0-git

interprocess_util.cc
Go to the documentation of this file.
1// Copyright (C) 2013-2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <util/ready_check.h>
10
11#include <gtest/gtest.h>
12
13#include <cstddef>
14
15namespace isc {
16namespace util {
17namespace unittests {
18
19unsigned char
20parentReadState(int fd) {
21 unsigned char result = 0xff;
22
23 const int nfds = util::selectCheck(fd, 5);
24 EXPECT_EQ(1, nfds);
25
26 if (nfds == 1) {
27 // Read status
28 const ssize_t bytes_read = read(fd, &result, sizeof(result));
29 EXPECT_EQ(static_cast<ssize_t>(sizeof(result)), bytes_read);
30 }
31
32 return (result);
33}
34
35}
36}
37}
isc::util::unittests
Definition check_valgrind.cc:11
isc::util::unittests::parentReadState
unsigned char parentReadState(int fd)
A helper utility for a simple synchronization with another process.
Definition interprocess_util.cc:20
isc::util
Definition time_utils.cc:43
isc::util::selectCheck
int selectCheck(const int fd_to_check, const unsigned int timeout_sec)
Definition ready_check.cc:14
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
ready_check.h