aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bun.js/webcore/streams.zig21
-rw-r--r--src/c.zig1
2 files changed, 18 insertions, 4 deletions
diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig
index eccab6fd0..176a96655 100644
--- a/src/bun.js/webcore/streams.zig
+++ b/src/bun.js/webcore/streams.zig
@@ -3932,7 +3932,15 @@ pub const File = struct {
},
};
- if (!auto_close) {
+ if ((file.is_atty orelse false) or (fd < 3 and std.os.isatty(fd))) {
+ var termios = std.mem.zeroes(std.os.termios);
+ _ = std.c.tcgetattr(fd, &termios);
+ bun.C.cfmakeraw(&termios);
+ file.is_atty = true;
+ }
+
+ if (!auto_close and !(file.is_atty orelse false)) {
+
// ensure we have non-blocking IO set
switch (Syscall.fcntl(fd, std.os.F.GETFL, 0)) {
.err => return .{ .err = Syscall.Error.fromCode(std.os.E.BADF, .fcntl) },
@@ -4395,12 +4403,14 @@ pub const FileReader = struct {
.blob => |blob| {
defer blob.deref();
var readable_file: File = .{ .loop = this.globalThis().bunVM().eventLoop() };
+
const result = readable_file.start(&blob.data.file);
if (result != .ready) {
return result;
}
- if (std.os.S.ISFIFO(readable_file.mode)) {
+ // for our purposes, ISCHR and ISFIFO are the same
+ if (std.os.S.ISFIFO(readable_file.mode) or std.os.S.ISCHR(readable_file.mode)) {
this.lazy_readable = .{
.readable = .{
.FIFO = FIFO{
@@ -4411,7 +4421,10 @@ pub const FileReader = struct {
},
};
this.lazy_readable.readable.FIFO.watch(readable_file.fd);
- this.lazy_readable.readable.FIFO.poll_ref.?.flags.insert(.nonblocking);
+ this.lazy_readable.readable.FIFO.pollRef().ref(this.globalThis().bunVM());
+ if (!(blob.data.file.is_atty orelse false)) {
+ this.lazy_readable.readable.FIFO.poll_ref.?.flags.insert(.nonblocking);
+ }
} else {
this.lazy_readable = .{
.readable = .{ .File = readable_file },
@@ -4543,7 +4556,7 @@ pub fn NewReadyWatcher(
}
if (comptime @hasField(Context, "mode")) {
- return std.os.S.ISFIFO(this.mode);
+ return std.os.S.ISFIFO(this.mode) or std.os.S.ISCHR(this.mode);
}
return false;
diff --git a/src/c.zig b/src/c.zig
index 1e4aca52c..ec9e63944 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -398,3 +398,4 @@ pub fn getRelease(buf: []u8) []const u8 {
}
pub extern fn memmem(haystack: [*]const u8, haystacklen: usize, needle: [*]const u8, needlelen: usize) ?[*]const u8;
+pub extern fn cfmakeraw(*std.os.termios) void;