feat(system,config,sqlite): implement VL-001, VL-003, VL-010, VL-011

This commit is contained in:
faumaray committed 2026-11-26 20:45:52 +03:00
1 parent adfc8548dc
commit b50131f52e
14 files changed
+2660 -139

No files matched your search

+54
View File
@@ -194,6 +194,57 @@ int mode_ignore_sigterm(int argc, char** argv)
return 0;
}
int mode_grandchild_ignore_sigterm(int argc, char** argv)
{
if (argc < 3) {
return usage_error("grandchild-ignore-sigterm requires <marker_file>");
}
const char* marker_path = argv[2];
int ready_p[2]{-1, -1};
if (::pipe(ready_p) != 0) {
return 1;
}
const pid_t gc = ::fork();
if (gc < 0) {
(void)::close(ready_p[0]);
(void)::close(ready_p[1]);
return 1;
}
if (gc == 0) {
(void)::close(ready_p[0]);
std::signal(SIGTERM, SIG_IGN);
const int mfd = ::open(marker_path, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644);
if (mfd < 0) {
(void)::close(ready_p[1]);
::_exit(1);
}
static constexpr char kTick[] = "tick\n";
(void)write_all_fd(mfd, kTick, sizeof(kTick) - 1);
static constexpr char kReady[] = "ready\n";
(void)write_all_fd(STDOUT_FILENO, kReady, sizeof(kReady) - 1);
const char one = '1';
(void)write_all_fd(ready_p[1], &one, 1);
(void)::close(ready_p[1]);
(void)::close(STDIN_FILENO);
(void)::close(STDOUT_FILENO);
(void)::close(STDERR_FILENO);
for (int iter = 0; iter < 500; ++iter) {
std::this_thread::sleep_for(std::chrono::milliseconds{10});
(void)write_all_fd(mfd, kTick, sizeof(kTick) - 1);
}
(void)::close(mfd);
::_exit(0);
}
(void)::close(ready_p[1]);
char dummy = 0;
bool eof = false;
(void)read_exact_fd(ready_p[0], &dummy, 1, eof);
(void)::close(ready_p[0]);
::_exit(0);
}
int mode_simultaneous_io(int argc, char** argv)
{
if (argc != 3) {
@@ -485,6 +536,9 @@ int main(int argc, char** argv)
if (mode == "ignore-sigterm") {
return mode_ignore_sigterm(argc, argv);
}
if (mode == "grandchild-ignore-sigterm") {
return mode_grandchild_ignore_sigterm(argc, argv);
}
if (mode == "simultaneous-io") {
return mode_simultaneous_io(argc, argv);
}