summaryrefslogtreecommitdiff
path: root/src/daemon.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon.zig')
-rw-r--r--src/daemon.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/daemon.zig b/src/daemon.zig
index dc86963d..f02c339e 100644
--- a/src/daemon.zig
+++ b/src/daemon.zig
@@ -359,10 +359,10 @@ pub fn setState(detached: bool) void {
/// This session's replica clients now, each its process's pid (0 when its
/// socket's peer is not known), for `--ps`.
pub fn clients(pids: []const libc.pid_t) void {
- var buf: [64]u8 = undefined;
+ var buf: ["clients".len + max_clients * " -2147483648".len]u8 = undefined;
var w: std.Io.Writer = .fixed(&buf);
- w.writeAll("clients") catch unreachable; // a literal fits 64
- for (pids[0..@min(pids.len, max_clients)]) |pid| w.print(" {d}", .{pid}) catch unreachable; // with max_clients pids, fits 64
+ w.writeAll("clients") catch unreachable; // a literal, its .len in buf's
+ for (pids[0..@min(pids.len, max_clients)]) |pid| w.print(" {d}", .{pid}) catch unreachable; // max_clients i32s, in buf's type
tell(w.buffered(), &.{});
}
@@ -761,15 +761,15 @@ const Daemon = struct {
/// TERM and marked, its pids answered; the shells of none kept, for
/// all of them.
fn kill(d: *Daemon, i: u8, named: ?[]const u8) void {
- var line: [msg_max]u8 = undefined;
+ var line: ["ok".len + max_conns * " -2147483648".len]u8 = undefined;
var w: std.Io.Writer = .fixed(&line);
- w.writeAll("ok") catch unreachable; // a literal fits msg_max
+ w.writeAll("ok") catch unreachable; // a literal, its .len in line's
var n: usize = 0;
for (&d.conns) |*s| if (s.fd >= 0 and s.kind != null) {
if (named) |want| if (!std.mem.eql(u8, s.named(), want)) continue;
s.killed = true;
_ = libc.kill(s.pid, .TERM);
- w.print(" {d}", .{s.pid}) catch unreachable; // max_conns pids after "ok" fit msg_max
+ w.print(" {d}", .{s.pid}) catch unreachable; // one i32 a conn, max_conns in line's type
n += 1;
};
if (named == null) {
@@ -954,7 +954,7 @@ const Daemon = struct {
return null;
}
if (count == 0) {
- w.print("no the detached session{s} running {s} {s}=<name>`", .{ if (others == 1) " is" else "s are", if (others == 1) "is" else "are each", other }) catch unreachable; // literals fit 511
+ w.print("no the detached session{s} running {s} {s}=<name>`", .{ if (others == 1) " is" else "s are", if (others == 1) "is" else "are each", other }) catch {}; // cut short, still 0-terminated
return null;
}
w.print("no {d} detached sessions are running; say which with --attach=<name>:", .{count}) catch unreachable; // a usize fits 511