diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/main.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/main.zig b/runtime/main.zig index 29c19bc0..be2aa54b 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -1842,8 +1842,11 @@ fn attachClient(init: std.process.Init, opts: pardes.Options, where: []const u8, Ssh.child = pid; Ssh.path = here; _ = atexit(Ssh.end); + // Its file is there a moment before ssh listens on it: until a + // connect answers. var waited: u32 = 0; - while (std.meta.isError(std.Io.Dir.cwd().access(io, here, .{}))) : (waited += 1) { + const probe = while (true) : (waited += 1) { + if (cloud9.transport.connectFd(.{ .unix = here }, cloud9.transport.nowMs() + 100)) |fd| break fd else |_| {} var status: c_int = 0; if (std.c.waitpid(pid, &status, std.c.W.NOHANG) == pid) { Ssh.child = 0; @@ -1852,7 +1855,8 @@ fn attachClient(init: std.process.Init, opts: pardes.Options, where: []const u8, if (waited > 3000) die(io, "--attach: ssh to {s} set up no forward in 30 s", .{where}); const ts: std.c.timespec = .{ .sec = 0, .nsec = 10 * std.time.ns_per_ms }; _ = std.c.nanosleep(&ts, null); - } + }; + _ = std.c.close(probe); clientOf(init, opts, here, name, true) catch |err| die(io, "--attach: {t}", .{err}); std.process.exit(0); } |
