summaryrefslogtreecommitdiff
path: root/Userland/Utilities/reboot.cpp
blob: f564c199a5898d59dc3058dc097a582abf2cc873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(int, char**)
{
    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 = "1";
    if (write(power_state_switch_node, value, 1) < 0) {
        perror("write");
        return 1;
    }
    return 0;
}