File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77#include < cfbox/applet.hpp>
88#include < cfbox/args.hpp>
99#include < cfbox/help.hpp>
10+ #include < cfbox/io.hpp>
1011
1112namespace {
1213
@@ -21,23 +22,21 @@ constexpr cfbox::help::HelpEntry HELP = {
2122
2223auto read_kmsg () -> std::vector<std::string> {
2324 std::vector<std::string> lines;
24- // Try /var/log/dmesg first (works without CAP_SYSLOG)
25- FILE * f = std::fopen (" /var/log/dmesg" , " r" );
26- if (!f) f = std::fopen (" /var/log/kern.log" , " r" );
25+ cfbox::io::unique_file f (std::fopen (" /var/log/dmesg" , " r" ));
26+ if (!f) f.reset (std::fopen (" /var/log/kern.log" , " r" ));
2727 if (!f) {
2828 std::fprintf (stderr, " cfbox dmesg: cannot open kernel log\n " );
2929 return lines;
3030 }
3131
3232 char buf[4096 ];
33- while (std::fgets (buf, sizeof (buf), f)) {
33+ while (std::fgets (buf, sizeof (buf), f. get () )) {
3434 auto len = std::strlen (buf);
3535 while (len > 0 && (buf[len - 1 ] == ' \n ' || buf[len - 1 ] == ' \r ' )) {
3636 buf[--len] = ' \0 ' ;
3737 }
3838 lines.emplace_back (buf);
3939 }
40- std::fclose (f);
4140 return lines;
4241}
4342
Original file line number Diff line number Diff line change 11#pragma once
22
33#include < chrono>
4+ #include < csignal>
45#include < cstdio>
56#include < string>
67#include < string_view>
@@ -54,9 +55,9 @@ struct InitState {
5455 RunLevel runlevel = RunLevel::SysInit;
5556 std::vector<InittabEntry> entries;
5657 std::vector<SpawnedProcess> children;
57- bool shutting_down = false ;
58- bool sigchld_received = false ;
59- bool sigint_received = false ;
58+ volatile sig_atomic_t shutting_down = 0 ;
59+ volatile sig_atomic_t sigchld_received = 0 ;
60+ volatile sig_atomic_t sigint_received = 0 ;
6061};
6162
6263// --- Module interfaces ---
Original file line number Diff line number Diff line change 33#include < csignal>
44#include < cstdio>
55#include < cstring>
6- #include < csignal>
76#include < unistd.h>
87#include < sys/reboot.h>
98#include < sys/mount.h>
You can’t perform that action at this time.
0 commit comments