First commit
This commit is contained in:
23
libexec/shut.c
Normal file
23
libexec/shut.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "config.h"
|
||||
|
||||
void shut(char c)
|
||||
{
|
||||
log("Saving seed...");
|
||||
{
|
||||
char buf[512];
|
||||
int input, output;
|
||||
|
||||
input = open("/dev/urandom", O_RDONLY);
|
||||
output = open(SEEDFILE, O_WRONLY);
|
||||
|
||||
write(output, buf, read(input, buf, sizeof(buf)));
|
||||
|
||||
close(input);
|
||||
close(output);
|
||||
}
|
||||
|
||||
log("Running programs...");
|
||||
runprgs((void *)shut_cmd, sizeof(shut_cmd) / sizeof(shut_cmd[0]));
|
||||
|
||||
reboot((c == 'r') ? RB_AUTOBOOT : RB_POWER_OFF);
|
||||
}
|
||||
Reference in New Issue
Block a user