On May 29 10:58, Jeremy Drake via Cygwin-patches wrote:
> This will allow checking for and optimizing cases that can easily be
> implemented using ch_spawn instead of using a full fork/exec.
> ---
>  winsup/cygwin/cygwin.din |  4 +--
>  winsup/cygwin/spawn.cc   | 70 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+), 2 deletions(-)
> 
> --- a/winsup/cygwin/spawn.cc
> +++ b/winsup/cygwin/spawn.cc
> @@ -1376,3 +1378,71 @@ __posix_spawn_execvpe (const char *path, char * const 
> *argv, char *const *envp,
>    __posix_spawn_sem_release (sem, errno);
>    return -1;
>  }
> +
> +/* HACK: duplicate some structs from newlib/libc/posix/posix_spawn.c */
> +struct __posix_spawn_file_actions {
> +  STAILQ_HEAD(, __posix_spawn_file_actions_entry) fa_list;
> +};
> +
> +typedef struct __posix_spawn_file_actions_entry {
> +  STAILQ_ENTRY(__posix_spawn_file_actions_entry) fae_list;
> +  enum {
> +    FAE_OPEN,
> +    FAE_DUP2,
> +    FAE_CLOSE,
> +    FAE_CHDIR,
> +    FAE_FCHDIR
> +  } 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;
> +    char *dir;
> +#define fae_dir              fae_data.dir
> +    int dirfd;
> +#define fae_dirfd            fae_data.dirfd
> +  } fae_data;
> +} posix_spawn_file_actions_entry_t;

That would be better defined in a common newlib header.


Thanks,
Corinna

Reply via email to