Skip to content

Commit 59f9de7

Browse files
halt: also update utmp
1 parent 6e355b9 commit 59f9de7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

halt.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ typedef enum {NOOP, HALT, REBOOT, POWEROFF} action_type;
1818
#define OUR_WTMP "/var/log/wtmp"
1919
#endif
2020

21+
#ifndef OUR_UTMP
22+
#define OUR_UTMP "/run/utmp"
23+
#endif
24+
2125
void write_wtmp(int boot) {
2226
int fd;
2327

@@ -42,6 +46,13 @@ void write_wtmp(int boot) {
4246

4347
write(fd, (char *)&utmp, sizeof(utmp));
4448
close(fd);
49+
50+
if (boot) {
51+
if ((fd = open(OUR_UTMP, O_WRONLY|O_APPEND)) < 0)
52+
return;
53+
write(fd, (char *)&utmp, sizeof utmp);
54+
close(fd);
55+
}
4556
}
4657

4758
int main(int argc, char *argv[]) {

0 commit comments

Comments
 (0)