Skip to content

Add posix_spawn bindings for FreeBSD #931

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

Merged
merged 1 commit into from
Feb 28, 2018

Conversation

bdrewery
Copy link
Contributor

No description provided.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@bdrewery
Copy link
Contributor Author

bdrewery commented Feb 28, 2018

I think these would apply for OpenBSD, and DragonFlyBSD, as well but I only am able to test FreeBSD right now.
This may not apply for NetBSD as their ABI is slightly different. For FreeBSD, OpenBSD, and DragonFlyBSD posix_spawnattr_t is an opaque pointer:

typedef struct __posix_spawnattr                *posix_spawnattr_t;
typedef struct __posix_spawn_file_actions       *posix_spawn_file_actions_t;

But on NetBSD it's not:

struct posix_spawnattr {
        short                   sa_flags;
        pid_t                   sa_pgroup;
        struct sched_param      sa_schedparam;
        int                     sa_schedpolicy;
        sigset_t                sa_sigdefault;
        sigset_t                sa_sigmask;
};

enum fae_action { FAE_OPEN, FAE_DUP2, FAE_CLOSE };
typedef struct posix_spawn_file_actions_entry {
        enum fae_action fae_action;

        int fae_fildes;
        union {
                struct {
                        char *path;
#define fae_path        fae_data.open.path
                        int oflag;
#define fae_oflag       fae_data.open.oflag
                        mode_t mode;
#define fae_mode        fae_data.open.mode
                } open;
                struct {
                        int newfildes;
#define fae_newfildes   fae_data.dup2.newfildes
                } dup2;
        } fae_data;
} posix_spawn_file_actions_entry_t;

struct posix_spawn_file_actions {
        unsigned int size;      /* size of fae array */
        unsigned int len;       /* how many slots are used */
        posix_spawn_file_actions_entry_t *fae;
};

typedef struct posix_spawnattr          posix_spawnattr_t;
typedef struct posix_spawn_file_actions posix_spawn_file_actions_t;

Do the field and sizes matter for declaring the types in the NetBSD case or would this still work?

pub type posix_spawnattr_t = *mut ::c_void;         
pub type posix_spawn_file_actions_t = *mut ::c_void;

@alexcrichton
Copy link
Member

Field sizes and such do need to be correct, but looks like this passed CI so it's all verified correct anyway!

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 28, 2018

📌 Commit 92d50c9 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Feb 28, 2018

⌛ Testing commit 92d50c9 with merge 8bed48a...

bors added a commit that referenced this pull request Feb 28, 2018
@bors
Copy link
Contributor

bors commented Feb 28, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 8bed48a to master...

@bors bors merged commit 92d50c9 into rust-lang:master Feb 28, 2018
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

Successfully merging this pull request may close these issues.

4 participants