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