Skip to content

The value of SIGCHLD is changed through binding in Linux docker container on MacOS #2979

Closed as duplicate of#2722
@sshwy

Description

@sshwy

Scenario: I'm currently developing my application in a docker container on MacOS. I wish to use kill and other related apis in Rust. Therefore I need to port those signal constants from C header to Rust. However I found that the value of SIGCHLD, which should be 17, is changed to 20.

The bindgen version is 0.65.1.

About the container (generate by Docker Desktop's dev container):

$ uname -a
Linux 64b26c15efbc 6.10.4-linuxkit #1 SMP Mon Aug 12 08:47:01 UTC 2024 aarch64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

Here's a mininal error reproduction (repo):

// main.rs
mod testit {
    #![allow(non_upper_case_globals)]
    #![allow(non_camel_case_types)]
    #![allow(non_snake_case)]
    #![allow(unused)]

    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}

fn main() {
    println!("Hello, world!");
    println!(
        "SIGCHLD = {}, but get_sigchld returns {}",
        testit::SIGCHLD,
        unsafe { testit::get_sigchld() }
    );
}
// testit.h
#include <unistd.h>
#include <signal.h>

#ifndef MY_LIB_H
#define MY_LIB_H

int get_sigchld();

#endif
// testit.c
#include "testit.h"

int get_sigchld() { return SIGCHLD; }

Performing cargo run gives the following output:

SIGCHLD = 20, but get_sigchld returns 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions