mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
shuffle some source around
This commit is contained in:
@ -14,16 +14,12 @@
|
|||||||
//! * posix_spawn is used for Mac, but doesn't support the necessary
|
//! * posix_spawn is used for Mac, but doesn't support the necessary
|
||||||
//! features for tty setup.
|
//! features for tty setup.
|
||||||
//!
|
//!
|
||||||
//! TODO:
|
|
||||||
//!
|
|
||||||
//! * Mac
|
|
||||||
//!
|
|
||||||
const Command = @This();
|
const Command = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const internal_os = @import("os/main.zig");
|
const internal_os = @import("os/main.zig");
|
||||||
const windows = @import("windows.zig");
|
const windows = internal_os.windows;
|
||||||
const TempDir = internal_os.TempDir;
|
const TempDir = internal_os.TempDir;
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
const os = std.os;
|
const os = std.os;
|
||||||
@ -297,15 +293,19 @@ fn setupFd(src: File.Handle, target: i32) !void {
|
|||||||
|
|
||||||
/// Wait for the command to exit and return information about how it exited.
|
/// Wait for the command to exit and return information about how it exited.
|
||||||
pub fn wait(self: Command, block: bool) !Exit {
|
pub fn wait(self: Command, block: bool) !Exit {
|
||||||
if (builtin.os.tag == .windows) {
|
if (comptime builtin.os.tag == .windows) {
|
||||||
|
// Block until the process exits. This returns immediately if the
|
||||||
// Block until the process exits. This returns immediately if the process already exited.
|
// process already exited.
|
||||||
const result = windows.kernel32.WaitForSingleObject(self.pid.?, windows.INFINITE);
|
const result = windows.kernel32.WaitForSingleObject(self.pid.?, windows.INFINITE);
|
||||||
if (result == windows.WAIT_FAILED) return windows.unexpectedError(windows.kernel32.GetLastError());
|
if (result == windows.WAIT_FAILED) {
|
||||||
|
return windows.unexpectedError(windows.kernel32.GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
var exit_code: windows.DWORD = undefined;
|
var exit_code: windows.DWORD = undefined;
|
||||||
var has_code = windows.kernel32.GetExitCodeProcess(self.pid.?, &exit_code) != 0;
|
var has_code = windows.kernel32.GetExitCodeProcess(self.pid.?, &exit_code) != 0;
|
||||||
if (!has_code) return windows.unexpectedError(windows.kernel32.GetLastError());
|
if (!has_code) {
|
||||||
|
return windows.unexpectedError(windows.kernel32.GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
return .{ .Exited = exit_code };
|
return .{ .Exited = exit_code };
|
||||||
}
|
}
|
||||||
@ -444,7 +444,7 @@ fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const EnvMap) ![:nu
|
|||||||
|
|
||||||
// Copied from Zig. This is a publicly exported function but there is no
|
// Copied from Zig. This is a publicly exported function but there is no
|
||||||
// way to get it from the std package.
|
// way to get it from the std package.
|
||||||
pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) ![]u16 {
|
fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) ![]u16 {
|
||||||
// count bytes needed
|
// count bytes needed
|
||||||
const max_chars_needed = x: {
|
const max_chars_needed = x: {
|
||||||
var max_chars_needed: usize = 4; // 4 for the final 4 null bytes
|
var max_chars_needed: usize = 4; // 4 for the final 4 null bytes
|
||||||
@ -571,7 +571,11 @@ test "Command: pre exec" {
|
|||||||
fn createTestStdout(dir: std.fs.Dir) !File {
|
fn createTestStdout(dir: std.fs.Dir) !File {
|
||||||
const file = try dir.createFile("stdout.txt", .{ .read = true });
|
const file = try dir.createFile("stdout.txt", .{ .read = true });
|
||||||
if (builtin.os.tag == .windows) {
|
if (builtin.os.tag == .windows) {
|
||||||
try windows.SetHandleInformation(file.handle, windows.HANDLE_FLAG_INHERIT, windows.HANDLE_FLAG_INHERIT);
|
try windows.SetHandleInformation(
|
||||||
|
file.handle,
|
||||||
|
windows.HANDLE_FLAG_INHERIT,
|
||||||
|
windows.HANDLE_FLAG_INHERIT,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const windows = @import("windows.zig");
|
const windows = @import("os/main.zig").windows;
|
||||||
const fd_t = std.os.fd_t;
|
const fd_t = std.os.fd_t;
|
||||||
|
|
||||||
const c = switch (builtin.os.tag) {
|
const c = switch (builtin.os.tag) {
|
||||||
@ -37,7 +37,6 @@ else
|
|||||||
/// of Linux syscalls. The caller is responsible for detail-oriented handling
|
/// of Linux syscalls. The caller is responsible for detail-oriented handling
|
||||||
/// of the returned file handles.
|
/// of the returned file handles.
|
||||||
pub const PosixPty = struct {
|
pub const PosixPty = struct {
|
||||||
|
|
||||||
// https://github.com/ziglang/zig/issues/13277
|
// https://github.com/ziglang/zig/issues/13277
|
||||||
// Once above is fixed, use `c.TIOCSCTTY`
|
// Once above is fixed, use `c.TIOCSCTTY`
|
||||||
const TIOCSCTTY = if (builtin.os.tag == .macos) 536900705 else c.TIOCSCTTY;
|
const TIOCSCTTY = if (builtin.os.tag == .macos) 536900705 else c.TIOCSCTTY;
|
||||||
|
@ -13,3 +13,4 @@ pub usingnamespace @import("resourcesdir.zig");
|
|||||||
pub const TempDir = @import("TempDir.zig");
|
pub const TempDir = @import("TempDir.zig");
|
||||||
pub const passwd = @import("passwd.zig");
|
pub const passwd = @import("passwd.zig");
|
||||||
pub const xdg = @import("xdg.zig");
|
pub const xdg = @import("xdg.zig");
|
||||||
|
pub const windows = @import("windows.zig");
|
||||||
|
@ -10,7 +10,7 @@ const ArenaAllocator = std.heap.ArenaAllocator;
|
|||||||
const EnvMap = std.process.EnvMap;
|
const EnvMap = std.process.EnvMap;
|
||||||
const termio = @import("../termio.zig");
|
const termio = @import("../termio.zig");
|
||||||
const Command = @import("../Command.zig");
|
const Command = @import("../Command.zig");
|
||||||
const Pty = @import("../Pty.zig").Pty;
|
const Pty = @import("../pty.zig").Pty;
|
||||||
const SegmentedPool = @import("../segmented_pool.zig").SegmentedPool;
|
const SegmentedPool = @import("../segmented_pool.zig").SegmentedPool;
|
||||||
const terminal = @import("../terminal/main.zig");
|
const terminal = @import("../terminal/main.zig");
|
||||||
const terminfo = @import("../terminfo/main.zig");
|
const terminfo = @import("../terminfo/main.zig");
|
||||||
@ -21,9 +21,9 @@ const trace = tracy.trace;
|
|||||||
const apprt = @import("../apprt.zig");
|
const apprt = @import("../apprt.zig");
|
||||||
const fastmem = @import("../fastmem.zig");
|
const fastmem = @import("../fastmem.zig");
|
||||||
const internal_os = @import("../os/main.zig");
|
const internal_os = @import("../os/main.zig");
|
||||||
|
const windows = internal_os.windows;
|
||||||
const configpkg = @import("../config.zig");
|
const configpkg = @import("../config.zig");
|
||||||
const shell_integration = @import("shell_integration.zig");
|
const shell_integration = @import("shell_integration.zig");
|
||||||
const windows = @import("../windows.zig");
|
|
||||||
|
|
||||||
const log = std.log.scoped(.io_exec);
|
const log = std.log.scoped(.io_exec);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user