概述
这篇文章讲解nginx的信号机制,因为是信号,所以其他方面的没有深究,放在后面分享出来,欢迎有兴趣的朋友留言交流
nginx运行的进程模式为master-worker的话,那master和worker进程间是通过信号来通信,关于信号相关的知识可以参考下面的链接Linux信号(signal) 机制分析
下面讲解代码执行流程都是以quit命令来执行的
一、信号的安装
nginx启动的过程中,master进程会安装自定义的信号处理机制,定义了哪些信号需要自己安装处理函数,nginx.c中的main函数中,有个ngx_init_signals函数就是用来安装自定义信号的,安装之后,后面fork出来的worker进程也会继承安装的自定义信号处理机制,因为fork出来的worker进程会复制一份和父进程一模一样的地址空间,包括所有资源,我们看下代码
ngx_int_t
ngx_init_signals(ngx_log_t *log)
{
ngx_signal_t
*sig;
struct sigaction
sa;
//signals已经是初始化过的全局变量,存储的就是各个信号的回调函数相关信息
for (sig = signals; sig->signo != 0; sig++) {
ngx_memzero(&sa, sizeof(struct sigaction));
if (sig->handler) {
sa.sa_sigaction = sig->handler;
sa.sa_flags = SA_SIGINFO;
} else {
sa.sa_handler = SIG_IGN;
}
sigemptyset(&sa.sa_mask);
if (sigaction(sig->signo, &sa, NULL) == -1) {
#if (NGX_VALGRIND)
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
"sigaction(%s) failed, ignored", sig->signame);
#else
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"sigaction(%s) failed", sig->signame);
return NGX_ERROR;
#endif
}
}
return NGX_OK;
}
接下来我们在看下signals这个全局变量的内容,这些信号就是对应nginx命令行的一些处理,例如nginx -s stop|quit|reload....
ngx_signal_t
signals[] = {
{ ngx_signal_value(NGX_RECONFIGURE_SIGNAL),
"SIG" ngx_value(NGX_RECONFIGURE_SIGNAL),
"reload",
ngx_signal_handler },
{ ngx_signal_value(NGX_REOPEN_SIGNAL),
"SIG" ngx_value(NGX_REOPEN_SIGNAL),
"reopen",
ngx_signal_handler },
{ ngx_signal_value(NGX_NOACCEPT_SIGNAL),
"SIG" ngx_value(NGX_NOACCEPT_SIGNAL),
"",
ngx_signal_handler },
{ ngx_signal_value(NGX_TERMINATE_SIGNAL),
"SIG" ngx_value(NGX_TERMINATE_SIGNAL),
"stop",
ngx_signal_handler },
{ ngx_signal_value(NGX_SHUTDOWN_SIGNAL),
"SIG" ngx_value(NGX_SHUTDOWN_SIGNAL),
"quit",
ngx_signal_handler },
{ ngx_signal_value(NGX_CHANGEBIN_SIGNAL),
"SIG" ngx_value(NGX_CHANGEBIN_SIGNAL),
"",
ngx_signal_handler },
{ SIGALRM, "SIGALRM", "", ngx_signal_handler },
{ SIGINT, "SIGINT", "", ngx_signal_handler },
{ SIGIO, "SIGIO", "", ngx_signal_handler },
{ SIGCHLD, "SIGCHLD", "", ngx_signal_handler },
{ SIGSYS, "SIGSYS, SIG_IGN", "", NULL },
{ SIGPIPE, "SIGPIPE, SIG_IGN", "", NULL },
{ 0, NULL, "", NULL }
};
安装完nginx要处理的信号之后,因为我们这篇讲的是nginx信号的机制,所以我们直接看ngx_master_process_cycle
二、 master进程阻塞等待信号
1、首先初始化一个信号集并且置空,sigemptyset(&set);
2、然后将需要处理的信号添加到信号集中,sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
3、先暂时用sigprocmask(SIG_BLOCK, &set, NULL),将上面的信号集阻塞,此刻如果有信号产生,内核不会把信号传递给进程,就是所谓的阻塞
4、然后信号集再置为空,sigemptyset(&set);
5、在master无限循环中,用sigsuspend(&set);,将之前阻塞的信号从掩码信号集中删除,然后挂起等待信号
就这样master进程就会阻塞在sigsuspend的调用中,直到有信号产生。
接下来我们看下如果有信号产生,接下来会怎么执行
当有信号产生的时候,nginx会捕获信号然后调用定义的信号处理函数(就是之前安装的信号处理器),信号处理函数主要是设置一些信号标识,然后sigsuspend调用返回,然后继续执行下面的代码,可以看源码中下面的
if (ngx_terminate) if (ngx_quit) 一些信号标识的判断,就是根据信号处理函数处理的信号标识进行不同的操作。
ngx_master_process_cycle(ngx_cycle_t *cycle)
{
char
*title;
u_char
*p;
size_t
size;
ngx_int_t
i;
ngx_uint_t
n, sigio;
sigset_t
set;
struct itimerval
itv;
ngx_uint_t
live;
ngx_msec_t
delay;
ngx_listening_t
*ls;
ngx_core_conf_t
*ccf;
//将参数set信号集初始化并清空
sigemptyset(&set);
//将参数signum 代表的信号加入至参数set 信号集里
//SIGCHLD子进程退出发出的信号
sigaddset(&set, SIGCHLD);
sigaddset(&set, SIGALRM);
sigaddset(&set, SIGIO);
sigaddset(&set, SIGINT);
sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL));
sigaddset(&set, ngx_signal_value(NGX_NOACCEPT_SIGNAL));
sigaddset(&set, ngx_signal_value(NGX_TERMINATE_SIGNAL));
sigaddset(&set, ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL));
//将上面的添加的信号集 添加进程掩码信号中,用来阻塞信号,内核不会把信号传递给进程
if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"sigprocmask() failed");
}
//将信号集置空,方便下面挂起进程的时候,删除阻塞的信号
sigemptyset(&set);
size = sizeof(master_process);
for (i = 0; i < ngx_argc; i++) {
size += ngx_strlen(ngx_argv[i]) + 1;
}
title = ngx_pnalloc(cycle->pool, size);
if (title == NULL) {
/* fatal */
exit(2);
}
p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
for (i = 0; i < ngx_argc; i++) {
*p++ = ' ';
p = ngx_cpystrn(p, (u_char *) ngx_argv[i], size);
}
//主进程进程NAME
//title:master process objs/ngin - /mnt/windows/nginx_study/nginx-1.15.8/conf/nginx.con
//printf("title:%sn", title);
ngx_setproctitle(title);
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
//子进程的启动,调用EPOLL和FASTCIG的INIT_PROCESS函数,事件的初始化,添加事件,阻塞,处理触发的事件
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
ngx_start_cache_manager_processes(cycle, 0);
ngx_new_binary = 0;
delay = 0;
sigio = 0;
live = 1;
//主进程的阻塞循环,挂起进程,等待信号
for ( ;; ) {
if (delay) {
if (ngx_sigalrm) {
sigio = 0;
delay *= 2;
ngx_sigalrm = 0;
}
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"termination cycle: %M", delay);
itv.it_interval.tv_sec = 0;
itv.it_interval.tv_usec = 0;
itv.it_value.tv_sec = delay / 1000;
itv.it_value.tv_usec = (delay % 1000 ) * 1000;
if (setitimer(ITIMER_REAL, &itv, NULL) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"setitimer() failed");
}
}
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "sigsuspend");
//先将之前阻塞的信号从掩码信号集中删除,然后挂起等待信号
//当主进程执行到这里的时候,一直会阻塞 直到有信号发生,才会返回,然后执行下面的代码
sigsuspend(&set);
ngx_time_update();
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"wake up, sigio %i", sigio);
if (ngx_reap) {
ngx_reap = 0;
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap children");
live = ngx_reap_children(cycle);
}
//live标志
表示是否还有子进程存活 0表示没有
》0表示还有存活的子进程
//当信号是退出信号的时候,要先等子进程全部退出后,主进程才会退出
if (!live && (ngx_terminate || ngx_quit)) {
ngx_master_process_exit(cycle);
}
//根据信号进行回调处理,并且把信号发送到各个子进程,让子进程也做相应的处理
if (ngx_terminate) {
if (delay == 0) {
delay = 50;
}
if (sigio) {
sigio--;
continue;
}
sigio = ccf->worker_processes + 2 /* cache processes */;
if (delay > 1000) {
ngx_signal_worker_processes(cycle, SIGKILL);
} else {
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_TERMINATE_SIGNAL));
}
continue;
}
if (ngx_quit) {
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
ls = cycle->listening.elts;
for (n = 0; n < cycle->listening.nelts; n++) {
if (ngx_close_socket(ls[n].fd) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
ngx_close_socket_n " %V failed",
&ls[n].addr_text);
}
}
cycle->listening.nelts = 0;
continue;
}
if (ngx_reconfigure) {
ngx_reconfigure = 0;
if (ngx_new_binary) {
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
ngx_start_cache_manager_processes(cycle, 0);
ngx_noaccepting = 0;
continue;
}
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring");
cycle = ngx_init_cycle(cycle);
if (cycle == NULL) {
cycle = (ngx_cycle_t *) ngx_cycle;
continue;
}
ngx_cycle = cycle;
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
ngx_core_module);
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_JUST_RESPAWN);
ngx_start_cache_manager_processes(cycle, 1);
/* allow new processes to start */
ngx_msleep(100);
live = 1;
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
}
if (ngx_restart) {
ngx_restart = 0;
ngx_start_worker_processes(cycle, ccf->worker_processes,
NGX_PROCESS_RESPAWN);
ngx_start_cache_manager_processes(cycle, 0);
live = 1;
}
if (ngx_reopen) {
ngx_reopen = 0;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
ngx_reopen_files(cycle, ccf->user);
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_REOPEN_SIGNAL));
}
if (ngx_change_binary) {
ngx_change_binary = 0;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "changing binary");
ngx_new_binary = ngx_exec_new_binary(cycle, ngx_argv);
}
if (ngx_noaccept) {
ngx_noaccept = 0;
ngx_noaccepting = 1;
ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
}
}
}
三、master进程接收到信号后
我们这里就用quit命令来作为例子看下接下来怎么运行
如果信号是ngx_quit的话,master进程就会用ngx_signal_worker_processes向worker进程同步命令
1、向所有worker进程发送ngx_write_channel(ngx_processes[i].channel[0],&ch, sizeof(ngx_channel_t), cycle->log),就是通过sockerpair建立的SOCKET来传递命令
2、kill(ngx_processes[i].pid, signo)向各个worker进程发送signo数值的信号
然后继续循环等待信号的产生直到所有worker进程退出后
//live标志 表示是否还有worker进程存活 0表示没有 》0表示还有存活的worker进程
//当信号是退出信号的时候,要先等子进程全部退出后,master进程才会退出
if (!live && (ngx_terminate || ngx_quit)) {
ngx_master_process_exit(cycle);
}
static void
ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
{
ngx_int_t
i;
ngx_err_t
err;
ngx_channel_t
ch;
ngx_memzero(&ch, sizeof(ngx_channel_t));
#if (NGX_BROKEN_SCM_RIGHTS)
ch.command = 0;
#else
switch (signo) {
case ngx_signal_value(NGX_SHUTDOWN_SIGNAL):
ch.command = NGX_CMD_QUIT;
break;
case ngx_signal_value(NGX_TERMINATE_SIGNAL):
ch.command = NGX_CMD_TERMINATE;
break;
case ngx_signal_value(NGX_REOPEN_SIGNAL):
ch.command = NGX_CMD_REOPEN;
break;
default:
ch.command = 0;
}
#endif
ch.fd = -1;
for (i = 0; i < ngx_last_process; i++) {
ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
"child: %i %P e:%d t:%d d:%d r:%d j:%d",
i,
ngx_processes[i].pid,
ngx_processes[i].exiting,
ngx_processes[i].exited,
ngx_processes[i].detached,
ngx_processes[i].respawn,
ngx_processes[i].just_spawn);
if (ngx_processes[i].detached || ngx_processes[i].pid == -1) {
continue;
}
if (ngx_processes[i].just_spawn) {
ngx_processes[i].just_spawn = 0;
continue;
}
//如果子进程正在退出,而且要传递的信号是退出信号,这不会重复发送
if (ngx_processes[i].exiting
&& signo == ngx_signal_value(NGX_SHUTDOWN_SIGNAL))
{
continue;
}
//master进程接受到的信号 传递给子进程
if (ch.command) {
if (ngx_write_channel(ngx_processes[i].channel[0],
&ch, sizeof(ngx_channel_t), cycle->log)
== NGX_OK)
{
if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
ngx_processes[i].exiting = 1;
}
continue;
}
}
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"kill (%P, %d)", ngx_processes[i].pid, signo);
if (kill(ngx_processes[i].pid, signo) == -1) {
err = ngx_errno;
ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
"kill(%P, %d) failed", ngx_processes[i].pid, signo);
if (err == NGX_ESRCH) {
ngx_processes[i].exited = 1;
ngx_processes[i].exiting = 0;
ngx_reap = 1;
}
continue;
}
if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
ngx_processes[i].exiting = 1;
}
}
}
四、worker进程接收到master信号之后的流程
这里有2个操作,
1、一个master进程直接调用kill函数来发送信号到子进程,这里还是quit命令为例,当worker进程收到master进程KILL过来的信号后,也是跟master接受到用户发送的信号执行流程一样,调用信号处理函数,执行一些资源关闭的操作。
这里有个问题,worker进程无限循环的时候没有用sigsuspend阻塞进程来等待信号,如果worker进程没有这个操作的话,就不会通过信号处理函数来设置信号标识,进而让子进程处理接下来的操作,希望了解的同学可以说一下
static void
ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
ngx_int_t worker = (intptr_t) data;
// printf("worker:%dn", (int) worker);
ngx_process = NGX_PROCESS_WORKER;
ngx_worker = worker;
//子进程初始化,清空复制的资源,添加事件
ngx_worker_process_init(cycle, worker);
//设置进程TITLE
ngx_setproctitle("worker process");
//子进程阻塞处理网络事件
for ( ;; ) {
if (ngx_exiting) {
if (ngx_event_no_timers_left() == NGX_OK) {
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
ngx_worker_process_exit(cycle);
}
}
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
//epoll_wait等待触发事件,并且根据回调处理事件
ngx_process_events_and_timers(cycle);
//处理master进程发送过来的 信号
if (ngx_terminate) {
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
ngx_worker_process_exit(cycle);
}
if (ngx_quit) {
ngx_quit = 0;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
"gracefully shutting down");
ngx_setproctitle("worker process is shutting down");
if (!ngx_exiting) {
ngx_exiting = 1;
ngx_set_shutdown_timer(cycle);
ngx_close_listening_sockets(cycle);
ngx_close_idle_connections(cycle);
}
}
if (ngx_reopen) {
ngx_reopen = 0;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
ngx_reopen_files(cycle, -1);
}
}
}
2、通过channel接受到master发送过来的指令,这个事件在子进程初始化的时候就添加到epoll事件管理里面,当有master进程向channel[0]写入指令的时候,子进程阻塞等待事件的时候就会触发,从channel[1]接受传过来的指令数据,然后调用事件回调函数ngx_channel_handler,主要是用来设置信号标识,让子进程在循环中执行相应的流程,最后ngx_worker_process_exit进程退出。
static void
ngx_channel_handler(ngx_event_t *ev)
{
ngx_int_t
n;
ngx_channel_t
ch;
ngx_connection_t
*c;
if (ev->timedout) {
ev->timedout = 0;
return;
}
c = ev->data;
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel handler");
for ( ;; ) {
//子进程读取父进程发送过来的数据-》就是命令
n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n);
if (n == NGX_ERROR) {
if (ngx_event_flags & NGX_USE_EPOLL_EVENT) {
ngx_del_conn(c, 0);
}
ngx_close_connection(c);
return;
}
if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
return;
}
}
if (n == NGX_AGAIN) {
return;
}
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
"channel command: %ui", ch.command);
//根据父进程发送过来的命令,进而控制子进程的状态
switch (ch.command) {
case NGX_CMD_QUIT:
ngx_quit = 1;
break;
case NGX_CMD_TERMINATE:
ngx_terminate = 1;
break;
case NGX_CMD_REOPEN:
ngx_reopen = 1;
break;
case NGX_CMD_OPEN_CHANNEL:
ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0,
"get channel s:%i pid:%P fd:%d",
ch.slot, ch.pid, ch.fd);
ngx_processes[ch.slot].pid = ch.pid;
ngx_processes[ch.slot].channel[0] = ch.fd;
break;
case NGX_CMD_CLOSE_CHANNEL:
ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0,
"close channel s:%i pid:%P our:%P fd:%d",
ch.slot, ch.pid, ngx_processes[ch.slot].pid,
ngx_processes[ch.slot].channel[0]);
if (close(ngx_processes[ch.slot].channel[0]) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
"close() channel failed");
}
ngx_processes[ch.slot].channel[0] = -1;
break;
}
}
}
五、worker进程退出后
当所有worker进程exit(0);退出后,用内核会向master进程发送一个SIGCHLD信号来告知master进程worker进程已经退出,在信号处理函数中,master进程会将信号标识ngx_reap,而且执行
if (signo == SIGCHLD) {
ngx_process_get_status();
}
waitpid等待worker进程退出相关信息,避免worker进程成为僵尸进程
然后在循环中执行,处理一些资源的回收,然后判断master进程是否可以退出
if (ngx_reap) {
ngx_reap = 0;
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap children");
live = ngx_reap_children(cycle);
}
//live标志
表示是否还有子进程存活 0表示没有
》0表示还有存活的子进程
//当信号是退出信号的时候,要先等子进程全部退出后,主进程才会退出
if (!live && (ngx_terminate || ngx_quit)) {
ngx_master_process_exit(cycle);
}
六、用户怎么向master进程发送quit命令
nginx -s quit就是让nginx平滑退出
通过ngx_get_options来判断当前命令行参数是否是信号操作,是的话就执行下面代码
从PID文件里面获取PID值,然后向对应的PID进程(master进程)kill对应的信号,接下来的操作就上面的三、四、五流程。
case 's':
if (*p) {
ngx_signal = (char *) p;
} else if (argv[++i]) {
ngx_signal = argv[i];
} else {
ngx_log_stderr(0, "option "-s" requires parameter");
return NGX_ERROR;
}
//ngx_signal:stop
//printf("ngx_signal:%sn", ngx_signal);
if (ngx_strcmp(ngx_signal, "stop") == 0
|| ngx_strcmp(ngx_signal, "quit") == 0
|| ngx_strcmp(ngx_signal, "reopen") == 0
|| ngx_strcmp(ngx_signal, "reload") == 0)
{
ngx_process = NGX_PROCESS_SIGNALLER;
goto next;
}
ngx_log_stderr(0, "invalid option: "-s %s"", ngx_signal);
return NGX_ERROR;
if (ngx_signal) {
return ngx_signal_process(cycle, ngx_signal);
}
ngx_int_t
ngx_signal_process(ngx_cycle_t *cycle, char *sig)
{
ssize_t
n;
ngx_pid_t
pid;
ngx_file_t
file;
ngx_core_conf_t
*ccf;
u_char
buf[NGX_INT64_LEN + 2];
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "signal process started");
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
ngx_memzero(&file, sizeof(ngx_file_t));
file.name = ccf->pid;
file.log = cycle->log;
file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY,
NGX_FILE_OPEN, NGX_FILE_DEFAULT_ACCESS);
if (file.fd == NGX_INVALID_FILE) {
ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno,
ngx_open_file_n " "%s" failed", file.name.data);
return 1;
}
n = ngx_read_file(&file, buf, NGX_INT64_LEN + 2, 0);
if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_close_file_n " "%s" failed", file.name.data);
}
if (n == NGX_ERROR) {
return 1;
}
while (n-- && (buf[n] == CR || buf[n] == LF)) { /* void */ }
pid = ngx_atoi(buf, ++n);
if (pid == (ngx_pid_t) NGX_ERROR) {
ngx_log_error(NGX_LOG_ERR, cycle->log, 0,
"invalid PID number "%*s" in "%s"",
n, buf, file.name.data);
return 1;
}
return ngx_os_signal_process(cycle, sig, pid);
}
最后
以上就是诚心学姐为你收集整理的nginx源码分析 (信号机制)的全部内容,希望文章能够帮你解决nginx源码分析 (信号机制)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复