File: spawn.h

package info (click to toggle)
watchman 4.9.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,992 kB
  • sloc: cpp: 27,459; python: 6,538; java: 3,404; php: 3,257; ansic: 2,803; javascript: 1,116; makefile: 671; ruby: 364; sh: 124; xml: 102; lisp: 4
file content (68 lines) | stat: -rw-r--r-- 1,954 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* Copyright 2014-present Facebook, Inc.
 * Licensed under the Apache License, Version 2.0 */
#pragma once

// Spawn attributes

typedef struct _posix_spawnattr {
  short flags;
  char *working_dir;
} posix_spawnattr_t;

#define POSIX_SPAWN_SETPGROUP 2

int posix_spawnattr_init(posix_spawnattr_t *attrp);
int posix_spawnattr_setflags(posix_spawnattr_t* attrp, short flags);
int posix_spawnattr_getflags(posix_spawnattr_t* attrp, short* flags);
int posix_spawnattr_destroy(posix_spawnattr_t *attrp);

int posix_spawnattr_setcwd_np(posix_spawnattr_t *attrp, const char *path);

// File actions
struct _posix_spawn_file_action {
  enum {
    open_file,
    dup_fd,
    dup_handle
  } action;
  int target_fd;
  union {
    intptr_t dup_local_handle;
    int source_fd;
    struct {
      char *name;
      int flags;
      int mode;
    } open_info;
  } u;
};

typedef struct _posix_spawn_file_actions {
  struct _posix_spawn_file_action *acts;
  int nacts;
} posix_spawn_file_actions_t;

int posix_spawn_file_actions_init(posix_spawn_file_actions_t *actions);
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *actions,
    int fd, int target_fd);
int posix_spawn_file_actions_adddup2_handle_np(
    posix_spawn_file_actions_t* actions,
    intptr_t handle,
    int target_fd);
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *actions,
    int target_fd, const char *name, int flags, int mode);
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *actions);

// And spawning itself

int posix_spawn(pid_t *pid, const char *path,
    const posix_spawn_file_actions_t *file_actions,
    const posix_spawnattr_t *attrp,
    char *const argv[], char *const envp[]);
int posix_spawnp(pid_t *pid, const char *file,
    const posix_spawn_file_actions_t *file_actions,
    const posix_spawnattr_t *attrp,
    char *const argv[], char *const envp[]);

#define WNOHANG 1
pid_t waitpid(pid_t pid, int* status, int options);