Skip to content

Large parts of (e.g.) sched.h not accessible without _GNU_SOURCE #229

@felixphew

Description

@felixphew

I'm experimenting with using Swift for some low(ish)-level Linux system programming, and I'd like to invoke the unshare(2) system call to create a new namespace.

unshare is normally exposed in C by sched.h (ultimately bits/sched.h). CSystem on Linux includes sched.h; however, as it doesn't define _GNU_SOURCE, most of bits/sched.h is not exposed, including the namespace (containerisation) functions clone, unshare, and setns (and their associated CLONE_* flags).

I understand the primary purpose of CSystem is to expose functionality that is then wrapped by System; and maybe one day System on Linux will include a wrapper for Linux namespaces: they're a compelling feature for the platform. Unfortunately, I'm not yet experienced enough with Swift to volunteer to write one.

In any case, would it be possible to #define _GNU_SOURCE in CSystem on Linux? What problems (if any) could this cause?

Other desirable system interfaces, often including safer alternatives to standard interfaces, are also gated behind it, e.g. get_current_dir_name, which was suggested for use in System in #71 (comment).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions