mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
Handle when the process already exited immediately
This commit is contained in:
@@ -1320,7 +1320,7 @@ pub const Subprocess = struct {
|
||||
)) {
|
||||
.result => {},
|
||||
.err => |err| {
|
||||
if (err.getErrno() == .SRCH) {
|
||||
if (err.getErrno() != .SRCH) {
|
||||
@panic("This shouldn't happen");
|
||||
}
|
||||
|
||||
|
||||
@@ -3656,7 +3656,9 @@ pub const FilePoll = struct {
|
||||
1,
|
||||
// The same array may be used for the changelist and eventlist.
|
||||
&changelist,
|
||||
1,
|
||||
// we set 0 here so that if we get an error on
|
||||
// registration, it becomes errno
|
||||
0,
|
||||
KEVENT_FLAG_ERROR_EVENTS,
|
||||
&timeout,
|
||||
);
|
||||
@@ -3679,10 +3681,9 @@ pub const FilePoll = struct {
|
||||
const errno = std.c.getErrno(rc);
|
||||
|
||||
if (errno != .SUCCESS) {
|
||||
switch (rc) {
|
||||
std.math.minInt(@TypeOf(rc))...-1 => return JSC.Maybe(void).errnoSys(@enumToInt(errno), .kevent).?,
|
||||
else => unreachable,
|
||||
}
|
||||
return JSC.Maybe(void){
|
||||
.err = JSC.Node.Syscall.Error.fromCode(errno, .kqueue),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
@compileError("TODO: Pollable");
|
||||
|
||||
@@ -130,38 +130,46 @@ for (let [gcTick, label] of [
|
||||
gcTick();
|
||||
});
|
||||
|
||||
// it("check exit code from onExit", async () => {
|
||||
// for (let i = 0; i < 1000; i++) {
|
||||
// var exitCode1, exitCode2;
|
||||
// await new Promise<void>((resolve) => {
|
||||
// var counter = 0;
|
||||
// spawn({
|
||||
// cmd: ["ls"],
|
||||
// onExit(code) {
|
||||
// exitCode1 = code;
|
||||
// counter++;
|
||||
// if (counter === 2) {
|
||||
// resolve();
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
it("check exit code from onExit", async () => {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
var exitCode1, exitCode2;
|
||||
await new Promise<void>((resolve) => {
|
||||
var counter = 0;
|
||||
spawn({
|
||||
cmd: ["ls"],
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
onExit(code) {
|
||||
console.log("first");
|
||||
exitCode1 = code;
|
||||
counter++;
|
||||
if (counter === 2) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// spawn({
|
||||
// cmd: ["false"],
|
||||
// onExit(code) {
|
||||
// exitCode2 = code;
|
||||
// counter++;
|
||||
// if (counter === 2) {
|
||||
// resolve();
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
spawn({
|
||||
cmd: ["false"],
|
||||
stdin: "ignore",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
onExit(code) {
|
||||
console.log("second");
|
||||
exitCode2 = code;
|
||||
counter++;
|
||||
if (counter === 2) {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// expect(exitCode1).toBe(0);
|
||||
// expect(exitCode2).toBe(1);
|
||||
// }
|
||||
// });
|
||||
expect(exitCode1).toBe(0);
|
||||
expect(exitCode2).toBe(1);
|
||||
}
|
||||
});
|
||||
|
||||
it("Blob works as stdin", async () => {
|
||||
rmSync("/tmp/out.123.txt", { force: true });
|
||||
|
||||
Reference in New Issue
Block a user