if (socketpair(AF_UNIX, SOCK_STREAM, 0, ngx_processes[s].channel) == -1) //建立父子进程通信的管道
{
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"socketpair() failed while spawning \"%s\"", name);
return NGX_INVALID_PID;
}
on = 1; //打开异步io
if (ioctl(ngx_processes[s].channel[0], FIOASYNC, &on) == -1) { //设置异步IO
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"ioctl(FIOASYNC) failed while spawning \"%s\"", name);
ngx_close_channel(ngx_processes[s].channel, cycle->log);
return NGX_INVALID_PID;
}
//看unix高级网络编程14.6.2BSD异步io
if (fcntl(ngx_processes[s].channel[0], F_SETOWN, ngx_pid) == -1) { //设置将接收SIGIO和SIGURG信号的进程id或进程组ID,进程组id通过提供负值的arg来说明,否则,arg将被认为所进程id
//SIGURG网络传来带外数据时产生,也是紧急套接口,SIGIO异步id(设置异步后必须设置),异步io是SIGIO和SIGURG组合
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"fcntl(F_SETOWN) failed while spawning \"%s\"", name);
ngx_close_channel(ngx_processes[s].channel, cycle->log);
return NGX_INVALID_PID;
}
if (fcntl(ngx_processes[s].channel[0], F_SETFD, FD_CLOEXEC) == -1) { //设置FD_CLOEXEC标志,在子进程里面没有关闭,在EXEC里面关闭,不拷贝进入
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"fcntl(FD_CLOEXEC) failed while spawning \"%s\"",
name);
ngx_close_channel(ngx_processes[s].channel, cycle->log);
return NGX_INVALID_PID;
}
阅读(2124) | 评论(0) | 转发(0) |