* @brief Set up standard I/O for a light-weight process * * @param[in] lwp Pointer to the light-weight process structure * * @note This function initializes the standard input, output, and error streams * for a light-weight process by opening the console device and associating * it with file descriptors 0, 1, and 2. */
| 253 | * it with file descriptors 0, 1, and 2. |
| 254 | */ |
| 255 | static void lwp_execve_setup_stdio(struct rt_lwp *lwp) |
| 256 | { |
| 257 | struct dfs_fdtable *lwp_fdt; |
| 258 | struct dfs_file *cons_file; |
| 259 | int cons_fd; |
| 260 | |
| 261 | lwp_fdt = &lwp->fdt; |
| 262 | |
| 263 | /* open console */ |
| 264 | cons_fd = open("/dev/console", O_RDWR); |
| 265 | if (cons_fd < 0) |
| 266 | { |
| 267 | LOG_E("%s: Cannot open console tty", __func__); |
| 268 | return ; |
| 269 | } |
| 270 | LOG_D("%s: open console as fd %d", __func__, cons_fd); |
| 271 | |
| 272 | /* init 4 fds */ |
| 273 | lwp_fdt->fds = rt_calloc(4, sizeof(void *)); |
| 274 | if (lwp_fdt->fds) |
| 275 | { |
| 276 | cons_file = fd_get(cons_fd); |
| 277 | lwp_fdt->maxfd = 4; |
| 278 | fdt_fd_associate_file(lwp_fdt, 0, cons_file); |
| 279 | fdt_fd_associate_file(lwp_fdt, 1, cons_file); |
| 280 | fdt_fd_associate_file(lwp_fdt, 2, cons_file); |
| 281 | } |
| 282 | |
| 283 | close(cons_fd); |
| 284 | return; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * @brief Entry point for light-weight process threads |
no test coverage detected