|
8 | 8 | #include <errno.h> |
9 | 9 | #include <stdlib.h> |
10 | 10 | #include <stdint.h> |
| 11 | +#include <unistd.h> |
11 | 12 | #include <string.h> |
12 | 13 | #include <stdbool.h> |
13 | 14 | #include <pthread.h> |
@@ -145,12 +146,23 @@ static const char *ocre_find_best_matching_runtime(const char *image) |
145 | 146 |
|
146 | 147 | struct ocre_container *ocre_container_create(const char *img_path, const char *workdir, const char *runtime, |
147 | 148 | const char *container_id, bool detached, |
148 | | - const struct ocre_container_args *arguments) |
| 149 | + const struct ocre_container_args *arguments, int stdin_fd, int stdout_fd, |
| 150 | + int stderr_fd) |
149 | 151 | { |
150 | 152 | int rc; |
151 | 153 | const char **capabilities = NULL; |
152 | 154 | const char **mounts = NULL; |
153 | 155 |
|
| 156 | + if (stdin_fd < 0) { |
| 157 | + stdin_fd = STDIN_FILENO; |
| 158 | + } |
| 159 | + if (stdout_fd < 0) { |
| 160 | + stdout_fd = STDOUT_FILENO; |
| 161 | + } |
| 162 | + if (stderr_fd < 0) { |
| 163 | + stderr_fd = STDERR_FILENO; |
| 164 | + } |
| 165 | + |
154 | 166 | if (!runtime) { |
155 | 167 | runtime = ocre_find_best_matching_runtime(img_path); |
156 | 168 | if (!runtime) { |
@@ -266,9 +278,9 @@ struct ocre_container *ocre_container_create(const char *img_path, const char *w |
266 | 278 | goto error_mutex; |
267 | 279 | } |
268 | 280 |
|
269 | | - container->runtime_context = |
270 | | - container->runtime->create(container_id, img_path, workdir, capabilities, |
271 | | - (const char **)container->argv, (const char **)container->envp, mounts); |
| 281 | + container->runtime_context = container->runtime->create( |
| 282 | + container_id, img_path, workdir, capabilities, (const char **)container->argv, |
| 283 | + (const char **)container->envp, mounts, stdin_fd, stdout_fd, stderr_fd); |
272 | 284 | if (!container->runtime_context) { |
273 | 285 | LOG_ERR("Failed to create container"); |
274 | 286 | goto error_cond; |
|
0 commit comments