Skip to content

can't get errno when libc lstat returns -1 #11878

@tw4452852

Description

@tw4452852

Zig Version

0.9.1

Steps to Reproduce

const std = @import("std");
const c = @cImport({
    @cInclude("sys/stat.h");
});

pub fn main() anyerror!void {
    var stbuf: c.struct_stat = undefined;
    const ret = c.lstat("/no/exist/path", &stbuf);
    std.debug.print("ret = {}, c.errno = {}\n", .{ ret, std.c._errno().* });
}

Expected Behavior

The output should be: ret = -1, c.errno = 2.

Actual Behavior

But the actual output is ret = -1, c.errno = 0. The errno is not set correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavioros-linuxLinuxstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions