24 lines
428 B
C
24 lines
428 B
C
#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);
|
|
}
|