2004-09-28 16:34:51 +08:00
|
|
|
|
|
|
|
/*
|
2004-09-30 00:00:49 +08:00
|
|
|
* Copyright (C) Igor Sysoev
|
2004-09-28 16:34:51 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-12-23 14:29:22 +08:00
|
|
|
#ifndef _NGX_PROCESS_H_INCLUDED_
|
|
|
|
#define _NGX_PROCESS_H_INCLUDED_
|
|
|
|
|
|
|
|
|
2005-07-25 17:41:38 +08:00
|
|
|
#include <ngx_setproctitle.h>
|
|
|
|
|
|
|
|
|
2003-11-20 00:26:41 +08:00
|
|
|
typedef pid_t ngx_pid_t;
|
|
|
|
|
2005-09-23 19:02:22 +08:00
|
|
|
#define NGX_INVALID_PID -1
|
|
|
|
|
2004-01-06 04:55:48 +08:00
|
|
|
typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ngx_pid_t pid;
|
|
|
|
int status;
|
2004-06-15 15:55:11 +08:00
|
|
|
ngx_socket_t channel[2];
|
2004-01-06 04:55:48 +08:00
|
|
|
|
|
|
|
ngx_spawn_proc_pt proc;
|
|
|
|
void *data;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
unsigned respawn:1;
|
2004-04-16 13:14:16 +08:00
|
|
|
unsigned just_respawn:1;
|
2004-01-06 04:55:48 +08:00
|
|
|
unsigned detached:1;
|
|
|
|
unsigned exiting:1;
|
2004-01-13 14:39:14 +08:00
|
|
|
unsigned exited:1;
|
2004-01-06 04:55:48 +08:00
|
|
|
} ngx_process_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *path;
|
|
|
|
char *name;
|
|
|
|
char *const *argv;
|
|
|
|
char *const *envp;
|
|
|
|
} ngx_exec_ctx_t;
|
|
|
|
|
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
#define NGX_MAX_PROCESSES 1024
|
2004-01-06 04:55:48 +08:00
|
|
|
|
2004-04-16 13:14:16 +08:00
|
|
|
#define NGX_PROCESS_NORESPAWN -1
|
|
|
|
#define NGX_PROCESS_RESPAWN -2
|
|
|
|
#define NGX_PROCESS_JUST_RESPAWN -3
|
|
|
|
#define NGX_PROCESS_DETACHED -4
|
2004-01-06 04:55:48 +08:00
|
|
|
|
|
|
|
|
2004-02-24 04:57:12 +08:00
|
|
|
#define ngx_getpid getpid
|
2005-10-10 20:59:41 +08:00
|
|
|
|
|
|
|
#ifndef ngx_log_pid
|
2004-02-24 04:57:12 +08:00
|
|
|
#define ngx_log_pid ngx_pid
|
2005-10-10 20:59:41 +08:00
|
|
|
#endif
|
|
|
|
|
2004-01-08 16:47:17 +08:00
|
|
|
|
2004-01-14 00:43:23 +08:00
|
|
|
ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
|
2005-02-22 22:40:13 +08:00
|
|
|
ngx_spawn_proc_pt proc, void *data, char *name, ngx_int_t respawn);
|
2004-03-05 00:34:23 +08:00
|
|
|
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
|
2005-09-07 00:09:32 +08:00
|
|
|
ngx_int_t ngx_init_signals(ngx_log_t *log);
|
2004-11-11 22:07:14 +08:00
|
|
|
void ngx_debug_point(void);
|
2004-06-23 13:54:27 +08:00
|
|
|
|
2004-10-21 23:34:38 +08:00
|
|
|
|
|
|
|
#if (NGX_HAVE_SCHED_YIELD)
|
2004-06-30 23:30:41 +08:00
|
|
|
#define ngx_sched_yield() sched_yield()
|
2004-10-21 23:34:38 +08:00
|
|
|
#else
|
|
|
|
#define ngx_sched_yield() usleep(1)
|
|
|
|
#endif
|
|
|
|
|
2004-06-30 23:30:41 +08:00
|
|
|
|
2004-10-11 23:07:03 +08:00
|
|
|
extern int ngx_argc;
|
|
|
|
extern char **ngx_argv;
|
|
|
|
extern char **ngx_os_argv;
|
2002-12-23 14:29:22 +08:00
|
|
|
|
2004-02-04 00:43:54 +08:00
|
|
|
extern ngx_pid_t ngx_pid;
|
2004-06-15 15:55:11 +08:00
|
|
|
extern ngx_socket_t ngx_channel;
|
2004-06-19 00:22:16 +08:00
|
|
|
extern ngx_int_t ngx_process_slot;
|
|
|
|
extern ngx_int_t ngx_last_process;
|
2004-01-06 04:55:48 +08:00
|
|
|
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];
|
2003-11-20 00:26:41 +08:00
|
|
|
|
|
|
|
|
2002-12-23 14:29:22 +08:00
|
|
|
#endif /* _NGX_PROCESS_H_INCLUDED_ */
|