* if is_timeout is true, we in signal handling context and can only * call async-safe functions */
| 179 | * call async-safe functions |
| 180 | */ |
| 181 | void parallel::finishChild(bool is_timeout) { |
| 182 | ensureChild(); |
| 183 | /* |
| 184 | * return the token before performing writes that may block. this |
| 185 | * results in a short-term load violation but also it prevents a |
| 186 | * deadlock |
| 187 | */ |
| 188 | putToken(); |
| 189 | if (is_timeout) { |
| 190 | const char *msg = "ERROR: Timeout asynchronous\n\n"; |
| 191 | safe_write(fd_to_parent, msg, std::strlen(msg)); |
| 192 | } else { |
| 193 | childProcess &me = children.back(); |
| 194 | auto data = std::move(me.output).str(); |
| 195 | auto size = data.size(); |
| 196 | ENSURE(safe_write(me.pipe[1], data.c_str(), size) == (ssize_t)size); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | void parallel::finishParent() { |
| 201 | ensureParent(); |
no test coverage detected