]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commit
cpp-example: run as a service
authorAdrian Freihofer <adrian.freihofer@siemens.com>
Tue, 3 Feb 2026 22:16:19 +0000 (23:16 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 12 Feb 2026 10:50:23 +0000 (10:50 +0000)
commitb5ea7f3dc0d3c9059f3fc423cef66af11d971f33
treec6f85c907bdd680ad6e3fa933d9acfc12afd2190
parentfe88b61e798a43f72e88abf06e8b04dec4244226
cpp-example: run as a service

Extend the C++ example to run as systemd/SysV services

This change adds service capability to the existing C++ example without
modifying its original behavior. The example can now run either as:
- One-shot executables (existing behavior)
- Long-running services via systemd or SysV init

The service runs as an unprivileged user/group, demonstrating security
best practices for service development. This introduces additional
complexity to the build process, particularly around proper pseudo usage
in development builds. The implementation includes:
- Service configuration files (systemd .service and SysV init script)
- Dedicated user/group creation with appropriate permissions
- JSON configuration file for runtime customization, owned by the
  service user
- Command-line --endless flag to enable service mode
- Full support for both CMake and Meson build systems

This enhancement enables testing debugger configurations that attach to
running processes, expanding the examples' utility for development tools.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
13 files changed:
meta-selftest/recipes-test/cpp/cpp-example.inc
meta-selftest/recipes-test/cpp/files/CMakeLists.txt
meta-selftest/recipes-test/cpp/files/config.h.in [new file with mode: 0644]
meta-selftest/recipes-test/cpp/files/cpp-example-lib.cpp
meta-selftest/recipes-test/cpp/files/cpp-example-lib.hpp
meta-selftest/recipes-test/cpp/files/cpp-example.conf [new file with mode: 0644]
meta-selftest/recipes-test/cpp/files/cpp-example.cpp
meta-selftest/recipes-test/cpp/files/cpp-example.init [new file with mode: 0644]
meta-selftest/recipes-test/cpp/files/cpp-example.service [new file with mode: 0644]
meta-selftest/recipes-test/cpp/files/meson.build
meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp
meta-selftest/recipes-test/cpp/meson-example.bb
meta/lib/oeqa/selftest/cases/devtool.py