mirror of
https://github.com/fairyglade/ly.git
synced 2026-05-06 07:10:36 +00:00
Fix log file race condition
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -417,19 +417,27 @@ fn xauth(log_file: *LogFile, allocator: std.mem.Allocator, io: std.Io, display_n
|
|||||||
|
|
||||||
const magic_cookie = mcookie(io);
|
const magic_cookie = mcookie(io);
|
||||||
|
|
||||||
|
log_file.deinit(io);
|
||||||
|
|
||||||
const pid = std.posix.system.fork();
|
const pid = std.posix.system.fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
|
try log_file.reinit(io);
|
||||||
|
|
||||||
var cmd_buffer: [1024]u8 = undefined;
|
var cmd_buffer: [1024]u8 = undefined;
|
||||||
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} add {s} . {s}", .{ options.xauth_cmd, display_name, magic_cookie }) catch std.process.exit(1);
|
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} add {s} . {s}", .{ options.xauth_cmd, display_name, magic_cookie }) catch std.process.exit(1);
|
||||||
|
|
||||||
try log_file.info(io, "auth/x11", "executing: {s} -c {s}", .{ shell, cmd_str });
|
try log_file.info(io, "auth/x11", "executing: {s} -c {s}", .{ shell, cmd_str });
|
||||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||||
_ = std.posix.system.execve(shell, &args, std.c.environ);
|
_ = std.posix.system.execve(shell, &args, std.c.environ);
|
||||||
|
|
||||||
|
log_file.deinit(io);
|
||||||
std.process.exit(1);
|
std.process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var status: c_int = undefined;
|
var status: c_int = undefined;
|
||||||
const result = std.posix.system.waitpid(pid, &status, 0);
|
const result = std.posix.system.waitpid(pid, &status, 0);
|
||||||
|
|
||||||
|
try log_file.reinit(io);
|
||||||
if (interop.isError(result) or status != 0) {
|
if (interop.isError(result) or status != 0) {
|
||||||
try log_file.err(
|
try log_file.err(
|
||||||
io,
|
io,
|
||||||
|
|||||||
Reference in New Issue
Block a user