summaryrefslogtreecommitdiff
path: root/Userland/shutdown.cpp
blob: 0d1900fbf78103bf9048f8168d9bb1d1763d20fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <LibCore/CArgsParser.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char** argv)
{
    CArgsParser args_parser("shutdown");
    args_parser.add_arg("n", "shut down now");
    CArgsParserResult args = args_parser.parse(argc, argv);

    if (args.is_present("n")) {
        if (halt() < 0) {
            perror("shutdown");
            return 1;
        }
    } else {
        args_parser.print_usage();
        return 0;
    }
}