mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
shutdown: Port to LibMain
This commit is contained in:
parent
2f1717182e
commit
55496ab7fb
Notes:
sideshowbarker
2024-07-17 19:53:52 +09:00
Author: https://github.com/alexmajor
Commit: 55496ab7fb
Pull-request: https://github.com/SerenityOS/serenity/pull/12034
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/bgianfo
Reviewed-by: https://github.com/kennethmyhra
Reviewed-by: https://github.com/mjz19910
2 changed files with 11 additions and 11 deletions
|
@ -1,25 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
||||
* Copyright (c) 2022, Alex Major
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/Stream.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int, char**)
|
||||
ErrorOr<int> serenity_main(Main::Arguments)
|
||||
{
|
||||
int power_state_switch_node = open("/sys/firmware/power_state", O_WRONLY);
|
||||
if (power_state_switch_node < 0) {
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
const char* value = "2";
|
||||
if (write(power_state_switch_node, value, 1) < 0) {
|
||||
perror("write");
|
||||
return 1;
|
||||
}
|
||||
auto file = TRY(Core::Stream::File::open("/sys/firmware/power_state", Core::Stream::OpenMode::Write));
|
||||
|
||||
const String file_contents = "2";
|
||||
TRY(file->write(file_contents.bytes()));
|
||||
file->close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue