MCPcopy Create free account
hub / github.com/acl-dev/acl / prepare_child_fds

Function prepare_child_fds

app/master/daemon/master/master_spawn.cpp:105–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103static ACL_VSTRING *env_gen = 0;
104
105static void prepare_child_fds(ACL_MASTER_SERV *serv)
106{
107 const char *myname = "prepare_child_fds";
108 int n;
109
110 /* MASTER_FLOW_READ_STREAM has been inited in master_vars.c */
111 if (acl_var_master_flow_pipe[0] <= ACL_MASTER_FLOW_READ) {
112 acl_msg_fatal("%s: flow pipe read descriptor <= %d",
113 myname, ACL_MASTER_FLOW_READ);
114 }
115
116 if (dup2(acl_var_master_flow_pipe[0], ACL_MASTER_FLOW_READ) < 0) {
117 acl_msg_fatal("%s: dup2: %s", myname, strerror(errno));
118 }
119
120 if (close(acl_var_master_flow_pipe[0]) < 0) {
121 acl_msg_fatal("close %d: %s",
122 acl_var_master_flow_pipe[0], strerror(errno));
123 }
124
125 /* MASTER_FLOW_WRITE_STREAM has been inited in master_vars.c */
126 if (acl_var_master_flow_pipe[1] <= ACL_MASTER_FLOW_WRITE) {
127 acl_msg_fatal("%s: flow pipe read descriptor <= %d",
128 myname, ACL_MASTER_FLOW_WRITE);
129 }
130 if (dup2(acl_var_master_flow_pipe[1], ACL_MASTER_FLOW_WRITE) < 0) {
131 acl_msg_fatal("%s: dup2: %s", myname, strerror(errno));
132 }
133 if (close(acl_var_master_flow_pipe[1]) < 0) {
134 acl_msg_fatal("close %d: %s",
135 acl_var_master_flow_pipe[1], strerror(errno));
136 }
137
138 /* Status channel */
139 acl_vstream_close(serv->status_reader);
140
141 /* MASTER_STAT_STREAM has been inited in master_vars.c*/
142 if (serv->status_fd[1] <= ACL_MASTER_STATUS_FD) {
143 acl_msg_fatal("%s: status file descriptor collision", myname);
144 }
145 if (dup2(serv->status_fd[1], ACL_MASTER_STATUS_FD) < 0) {
146 acl_msg_fatal("%s: dup2 status_fd: %s", myname, strerror(errno));
147 }
148
149 close(serv->status_fd[1]);
150
151 for (n = 0; n < serv->listen_fd_count; n++) {
152 if (serv->listen_fds[n] <= ACL_MASTER_LISTEN_FD + n) {
153 acl_msg_fatal("%s: listen fd collision", myname);
154 }
155 if (dup2(serv->listen_fds[n], ACL_MASTER_LISTEN_FD + n) < 0) {
156 acl_msg_fatal("%s: dup2 listen_fd %d: %s",
157 myname, serv->listen_fds[n], strerror(errno));
158 }
159 acl_msg_info("%s: dup listen fd from %d to %d in %s mode",
160 myname, serv->listen_fds[n], ACL_MASTER_LISTEN_FD + n,
161 acl_is_blocking(ACL_MASTER_LISTEN_FD + n) == 1 ?
162 "non-blocking" : "blocking");

Callers 1

start_childFunction · 0.85

Calls 6

acl_msg_fatalFunction · 0.85
acl_vstream_closeFunction · 0.85
acl_msg_infoFunction · 0.85
acl_is_blockingFunction · 0.85
acl_vstream_freeFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…