We rely on the fact that lightningd terminates all JSON RPC responses with * "\n\n", so we can stream even if we can't parse. */
| 390 | /* We rely on the fact that lightningd terminates all JSON RPC responses with |
| 391 | * "\n\n", so we can stream even if we can't parse. */ |
| 392 | static void oom_dump(int fd, char *resp, size_t off) |
| 393 | { |
| 394 | warnx("Out of memory: sending raw output"); |
| 395 | |
| 396 | /* Note: resp does not already end in '\n\n', and resp_len is > 0 */ |
| 397 | do { |
| 398 | /* Keep last char, to avoid splitting \n\n */ |
| 399 | write_all(STDOUT_FILENO, resp, off-1); |
| 400 | resp[0] = resp[off-1]; |
| 401 | off = 1 + read_nofail(fd, resp + 1, tal_bytelen(resp) - 1); |
| 402 | } while (resp[off-2] != '\n' || resp[off-1] != '\n'); |
| 403 | write_all(STDOUT_FILENO, resp, off-1); |
| 404 | /* We assume giant answer means "success" */ |
| 405 | exit(0); |
| 406 | } |
| 407 | |
| 408 | /* We want to return failure if tal_resize fails */ |
| 409 | static void tal_error(const char *msg) |
no test coverage detected