ngx_int_tngx_signal_process(ngx_cycle_t*cycle,char*sig){ssize_tn;ngx_pid_tpid;ngx_file_tfile;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);return1;}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){return1;}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);return1;}returnngx_os_signal_process(cycle,sig,pid);}
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);return1;}