Skip to content

wait() status functions (std.os.linux.W) return values differ from c #24788

@pmovzxdq

Description

@pmovzxdq

Zig Version

0.14.1

Steps to Reproduce and Observed Behavior

As an example, I have the following c code:

// test.c

#include <sys/wait.h>
#include <stdio.h>

int main() {
    int s = 0x0080;
    printf("%d, %d, %d, %d\n", WIFEXITED(s), WIFSTOPPED(s), WIFSIGNALED(s), WIFCONTINUED(s));
    return 0;
}

I also have this zig code:

// test.zig

const std = @import("std");

pub fn main() !void {
    const s: u32 = 0x0080;
    std.debug.print("{}, {}, {}\n", .{
        std.os.linux.W.IFEXITED(s),
        std.os.linux.W.IFSTOPPED(s),
        std.os.linux.W.IFSIGNALED(s),
        // std.os.linux.W.IFCONTINUED(s)
    });
}

The result is different:

$ zig run test.zig
true, true, true
$ gcc test.c; ./a.out
1, 0, 0, 0

Zig also does not have an equivalent function for the WIFCONTINUED(s) macro.

Expected Behavior

The result should be the same, and zig should implement the IFCONTINUED function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.os-linuxstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions