Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.io.poll broken on Windows #22991

Open
DivergentClouds opened this issue Feb 23, 2025 · 0 comments
Open

std.io.poll broken on Windows #22991

DivergentClouds opened this issue Feb 23, 2025 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@DivergentClouds
Copy link

DivergentClouds commented Feb 23, 2025

Zig Version

0.14.0-dev.3287+65e7ede49

Steps to Reproduce and Observed Behavior

Running the following tests on Windows,results in the first 2 tests hanging and the third returning an error. You must use test filters to run all tests.

const std = @import("std");
const builtin = @import("builtin");

test "poll stdin" {
    const allocator = std.testing.allocator;
    var poller = std.io.poll(
        allocator,
        enum { stdin },
        .{ .stdin = std.io.getStdIn() },
    );
    defer poller.deinit();

    // never returns
    _ = try poller.pollTimeout(1);
}

test "poll file with data" {
    const allocator = std.testing.allocator;
    var tmp = std.testing.tmpDir(.{});
    defer tmp.cleanup();

    const file = try tmp.dir.createFile("foo", .{ .read = true });
    defer file.close();

    try file.writeAll("bar");

    var poller = std.io.poll(
        allocator,
        enum { file },
        .{ .file = file },
    );
    defer poller.deinit();
    // never returns
    _ = try poller.pollTimeout(1);
}

test "poll empty file" {
    const allocator = std.testing.allocator;
    var tmp = std.testing.tmpDir(.{});
    defer tmp.cleanup();

    const file = try tmp.dir.createFile("foo", .{ .read = true });
    defer file.close();

    var poller = std.io.poll(
        allocator,
        enum { file },
        .{ .file = file },
    );
    defer poller.deinit();
    // fails with `error.Unexpected: GetLastError(38): Reached the end of the file.`
    _ = try poller.pollTimeout(1);
}

Expected Behavior

All tests should return successfully. This behaves correctly on Linux.

@DivergentClouds DivergentClouds added the bug Observed behavior contradicts documented or intended behavior label Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant