Don't forget to flush... :)

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2025-08-29 22:54:05 +02:00
parent 38c3ecd089
commit 230874abd1
2 changed files with 14 additions and 4 deletions

View File

@@ -90,7 +90,8 @@ pub fn authenticate(allocator: std.mem.Allocator, log_writer: *std.Io.Writer, op
child_pid = try std.posix.fork(); child_pid = try std.posix.fork();
if (child_pid == 0) { if (child_pid == 0) {
try log_writer.writeAll("starting session"); try log_writer.writeAll("starting session\n");
try log_writer.flush();
startSession(log_writer, allocator, options, tty_str, user_entry, handle, current_environment) catch |e| { startSession(log_writer, allocator, options, tty_str, user_entry, handle, current_environment) catch |e| {
shared_err.writeError(e); shared_err.writeError(e);
@@ -377,7 +378,7 @@ fn xauth(log_writer: *std.Io.Writer, allocator: std.mem.Allocator, display_name:
const status = std.posix.waitpid(pid, 0); const status = std.posix.waitpid(pid, 0);
if (status.status != 0) { if (status.status != 0) {
try log_writer.print("xauth command failed with status {d}", .{status.status}); try log_writer.print("xauth command failed with status {d}\n", .{status.status});
return error.XauthFailed; return error.XauthFailed;
} }
} }

View File

@@ -229,6 +229,13 @@ pub fn main() !void {
var log_buffer: [1024]u8 = undefined; var log_buffer: [1024]u8 = undefined;
var log_file_writer = log_file.writer(&log_buffer); var log_file_writer = log_file.writer(&log_buffer);
// Seek to the end of the log file
if (could_open_log_file) {
const stat = try log_file.stat();
try log_file_writer.seekTo(stat.size);
}
var log_writer = &log_file_writer.interface; var log_writer = &log_file_writer.interface;
// These strings only end up getting freed if the user quits Ly using Ctrl+C, which is fine since in the other cases // These strings only end up getting freed if the user quits Ly using Ctrl+C, which is fine since in the other cases
@@ -787,7 +794,7 @@ pub fn main() !void {
update = true; update = true;
}, },
termbox.TB_KEY_ENTER => authenticate: { termbox.TB_KEY_ENTER => authenticate: {
try log_writer.writeAll("authenticating..."); try log_writer.writeAll("authenticating...\n");
if (!config.allow_empty_password and password.text.items.len == 0) { if (!config.allow_empty_password and password.text.items.len == 0) {
// Let's not log this message for security reasons // Let's not log this message for security reasons
@@ -898,7 +905,7 @@ pub fn main() !void {
password.clear(); password.clear();
try info_line.addMessage(lang.logout, config.bg, config.fg); try info_line.addMessage(lang.logout, config.bg, config.fg);
try log_writer.writeAll("logged out"); try log_writer.writeAll("logged out\n");
} }
try std.posix.tcsetattr(std.posix.STDIN_FILENO, .FLUSH, tb_termios); try std.posix.tcsetattr(std.posix.STDIN_FILENO, .FLUSH, tb_termios);
@@ -955,6 +962,8 @@ pub fn main() !void {
update = true; update = true;
}, },
} }
try log_writer.flush();
} }
} }