Compare commits
No commits in common. "4becb2e4276dbc23df264278570d3d24357bfdc8" and "0f377e728908c1536f8524d0c855feabea4ef5bc" have entirely different histories.
4becb2e427
...
0f377e7289
@ -3,7 +3,6 @@
|
|||||||
#include <luna/PathParser.h>
|
#include <luna/PathParser.h>
|
||||||
#include <luna/Sort.h>
|
#include <luna/Sort.h>
|
||||||
#include <luna/String.h>
|
#include <luna/String.h>
|
||||||
#include <luna/Utf8.h>
|
|
||||||
#include <luna/Vector.h>
|
#include <luna/Vector.h>
|
||||||
#include <os/ArgumentParser.h>
|
#include <os/ArgumentParser.h>
|
||||||
#include <os/Directory.h>
|
#include <os/Directory.h>
|
||||||
@ -25,6 +24,18 @@ static bool g_is_system = false;
|
|||||||
|
|
||||||
FILE* g_init_log = nullptr;
|
FILE* g_init_log = nullptr;
|
||||||
|
|
||||||
|
// Request a successful exit from the system (for tests)
|
||||||
|
void sigterm_handler(int)
|
||||||
|
{
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request a failure exit from the system (for tests)
|
||||||
|
void sigquit_handler(int)
|
||||||
|
{
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
struct Service
|
struct Service
|
||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
@ -52,20 +63,6 @@ static void do_log(const char* format, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request a successful exit from the system (for tests)
|
|
||||||
void sigterm_handler(int)
|
|
||||||
{
|
|
||||||
do_log("[init] successful exit requested, complying\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Request a failure exit from the system (for tests)
|
|
||||||
void sigquit_handler(int)
|
|
||||||
{
|
|
||||||
do_log("[init] failure exit requested, complying\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Result<void> service_child(const Service& service, SharedPtr<os::File> output, SharedPtr<os::File> error,
|
static Result<void> service_child(const Service& service, SharedPtr<os::File> output, SharedPtr<os::File> error,
|
||||||
SharedPtr<os::File> input)
|
SharedPtr<os::File> input)
|
||||||
{
|
{
|
||||||
@ -303,19 +300,6 @@ static Result<void> set_hostname()
|
|||||||
auto hostname = TRY(file->read_line());
|
auto hostname = TRY(file->read_line());
|
||||||
hostname.trim("\n");
|
hostname.trim("\n");
|
||||||
|
|
||||||
if (hostname.is_empty())
|
|
||||||
{
|
|
||||||
do_log("[init] /etc/hostname is empty or invalid, keeping the default hostname\n");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
Utf8StringDecoder decoder(hostname.chars());
|
|
||||||
if (decoder.code_points().has_error())
|
|
||||||
{
|
|
||||||
do_log("[init] /etc/hostname is not valid UTF-8, keeping the default hostname\n");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sethostname(hostname.chars(), hostname.length()) < 0) return {};
|
if (sethostname(hostname.chars(), hostname.length()) < 0) return {};
|
||||||
|
|
||||||
do_log("[init] successfully set system hostname to '%s'\n", hostname.chars());
|
do_log("[init] successfully set system hostname to '%s'\n", hostname.chars());
|
||||||
|
Loading…
Reference in New Issue
Block a user