mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
25 lines
375 B
C
25 lines
375 B
C
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "common.h"
|
|
|
|
int main() {
|
|
char c = COMMAND_POWEROFF;
|
|
int fd = open(COMMAND_FIFO, O_WRONLY);
|
|
|
|
if (fd == -1) {
|
|
perror("poweroff: open");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
if (write(fd, &c, 1) < 0) {
|
|
perror("poweroff: write");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
close(fd);
|
|
return EXIT_SUCCESS;
|
|
}
|