Skip to content

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

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

Open
felixphew opened this issue May 6, 2025 · 0 comments
Open

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

felixphew opened this issue May 6, 2025 · 0 comments

Comments

@felixphew
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant