| /* Copyright 2021 The ChromiumOS Authors |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| #define MAX_PIPE_CAPACITY (4096) |
| FILE *write_to_pipe(const std::string& content) |
| if (pipe(pipefd) == -1) { |
| die("pipe(pipefd) failed"); |
| size_t len = content.length(); |
| if (len > MAX_PIPE_CAPACITY) |
| die("write_to_pipe cannot handle >4KB content."); |
| unsigned int attempts = 0; |
| ret = write(pipefd[1], content.c_str() + i, len - i); |
| /* If we write 0 bytes three times in a row, fail. */ |
| warn("write() returned 0 three times in a row"); |
| return fdopen(pipefd[0], "r"); |
| std::string source_path(const std::string& file) { |
| std::string srcdir = getenv("SRC") ? : "."; |
| return srcdir + "/" + file; |