1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
5 */
6
7
8#ifndef _NGX_PROCESS_H_INCLUDED_
9#define _NGX_PROCESS_H_INCLUDED_
10
11
12typedef DWORD               ngx_pid_t;
13#define NGX_INVALID_PID     0
14
15
16#define ngx_getpid          GetCurrentProcessId
17#define ngx_log_pid         ngx_pid
18
19
20#define NGX_PROCESS_SYNC_NAME                                                 \
21    (sizeof("ngx_cache_manager_mutex_") + NGX_INT32_LEN)
22
23
24typedef uint64_t            ngx_cpuset_t;
25
26
27typedef struct {
28    HANDLE                  handle;
29    ngx_pid_t               pid;
30    char                   *name;
31
32    HANDLE                  term;
33    HANDLE                  quit;
34    HANDLE                  reopen;
35
36    u_char                  term_event[NGX_PROCESS_SYNC_NAME];
37    u_char                  quit_event[NGX_PROCESS_SYNC_NAME];
38    u_char                  reopen_event[NGX_PROCESS_SYNC_NAME];
39
40    unsigned                just_spawn:1;
41    unsigned                exiting:1;
42} ngx_process_t;
43
44
45typedef struct {
46    char                   *path;
47    char                   *name;
48    char                   *args;
49    char *const            *argv;
50    char *const            *envp;
51    HANDLE                  child;
52} ngx_exec_ctx_t;
53
54
55ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn);
56ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
57
58#define ngx_debug_point()
59#define ngx_sched_yield()   SwitchToThread()
60
61
62#define NGX_MAX_PROCESSES         (MAXIMUM_WAIT_OBJECTS - 4)
63
64#define NGX_PROCESS_RESPAWN       -2
65#define NGX_PROCESS_JUST_RESPAWN  -3
66
67
68extern int                  ngx_argc;
69extern char               **ngx_argv;
70extern char               **ngx_os_argv;
71
72extern ngx_int_t            ngx_last_process;
73extern ngx_process_t        ngx_processes[NGX_MAX_PROCESSES];
74
75extern ngx_pid_t            ngx_pid;
76
77
78#endif /* _NGX_PROCESS_H_INCLUDED_ */
79