init: poweroff program

This commit is contained in:
Matheus
2024-09-01 22:53:37 -03:00
parent d42572b041
commit a876a61d08
5 changed files with 190 additions and 45 deletions
+24
View File
@@ -0,0 +1,24 @@
#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)) {
perror("poweroff: write");
return EXIT_FAILURE;
}
close(fd);
return EXIT_SUCCESS;
}