Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
dave caruso
2024-02-05 10:06:23 -08:00
committed by GitHub
parent bd4d0d15db
commit 48ed1dfb65
4 changed files with 33 additions and 7 deletions

View File

@@ -2680,3 +2680,5 @@ pub fn getUserName(output_buffer: []u8) ?[]const u8 {
pub var buffered_stdin = std.io.BufferedReader(4096, std.fs.File.Reader){
.unbuffered_reader = std.fs.File.Reader{ .context = .{ .handle = if (Environment.isWindows) undefined else 0 } },
};
pub const WindowsSpawnWorkaround = @import("./child_process_windows.zig");

View File

@@ -458,7 +458,14 @@ pub const BunxCommand = struct {
child_process.stderr_behavior = .Inherit;
child_process.stdin_behavior = .Inherit;
child_process.stdout_behavior = .Inherit;
const term = try child_process.spawnAndWait();
if (Environment.isWindows) {
try bun.WindowsSpawnWorkaround.spawnWindows(&child_process);
} else {
try child_process.spawn();
}
const term = try child_process.wait();
switch (term) {
.Exited => |exit_code| {

View File

@@ -151,7 +151,14 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string,
proc.stdout_behavior = .Inherit;
proc.stderr_behavior = .Inherit;
proc.cwd = cwd;
_ = proc.spawnAndWait() catch undefined;
if (Environment.isWindows) {
bun.WindowsSpawnWorkaround.spawnWindows(&proc) catch return;
} else {
proc.spawn() catch return;
}
_ = proc.wait() catch {};
}
// We don't want to allocate memory each time
@@ -1434,9 +1441,13 @@ pub const CreateCommand = struct {
Output.flush();
}
_ = try process.spawnAndWait();
_ = process.kill() catch undefined;
if (Environment.isWindows) {
try bun.WindowsSpawnWorkaround.spawnWindows(&process);
} else {
try process.spawn();
}
_ = try process.wait();
_ = try process.kill();
}
if (postinstall_tasks.items.len > 0) {

View File

@@ -348,7 +348,7 @@ pub const RunCommand = struct {
child_process.stdout_behavior = .Inherit;
if (Environment.isWindows) {
try @import("../child_process_windows.zig").spawnWindows(&child_process);
try bun.WindowsSpawnWorkaround.spawnWindows(&child_process);
} else {
try child_process.spawn();
}
@@ -434,7 +434,13 @@ pub const RunCommand = struct {
child_process.stdout_behavior = .Inherit;
const silent = ctx.debug.silent;
const result = child_process.spawnAndWait() catch |err| {
if (Environment.isWindows) {
try bun.WindowsSpawnWorkaround.spawnWindows(&child_process);
} else {
try child_process.spawn();
}
const result = child_process.wait() catch |err| {
if (err == error.AccessDenied) {
if (comptime Environment.isPosix) {
var stat = std.mem.zeroes(std.c.Stat);