Changeset 3562


Ignore:
Timestamp:
Mar 8, 2022, 12:10:40 PM (3 years ago)
Author:
bird
Message:

kmk_redirect: Must redirect stdout/err according to the pCtx when not on windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/redirect.c

    r3412 r3562  
    14181418#ifdef USE_POSIX_SPAWN
    14191419    /*
    1420      * Init posix attributes.
     1420     * Init posix attributes with stdout/err redirections according to pCtx.
    14211421     */
    14221422    rcExit = posix_spawn_file_actions_init(&FileActions);
    14231423    if (rcExit != 0)
    14241424        rcExit = errx(pCtx, 9, "posix_spawn_file_actions_init failed: %s", strerror(rcExit));
     1425# ifndef CONFIG_WITH_OUTPUT_IN_MEMORY
     1426    if (pCtx->pOut && rcExit == 0)
     1427    {
     1428        if (pCtx->pOut->out >= 0)
     1429        {
     1430            rcExit = posix_spawn_file_actions_adddup2(&FileActions, pCtx->pOut->out, 1);
     1431            if (rcExit != 0)
     1432                rcExit = errx(pCtx, 2, "posix_spawn_file_actions_addclose(%d, 1) failed: %s", pCtx->pOut->out, strerror(rcExit));
     1433        }
     1434        if (pCtx->pOut->err >= 0 && rcExit == 0)
     1435        {
     1436            rcExit = posix_spawn_file_actions_adddup2(&FileActions, pCtx->pOut->err, 2);
     1437            if (rcExit != 0)
     1438                rcExit = errx(pCtx, 2, "posix_spawn_file_actions_addclose(%d, 1) failed: %s", pCtx->pOut->err, strerror(rcExit));
     1439        }
     1440    }
     1441# endif
    14251442#endif
    14261443
     
    17611778                        rcExit = posix_spawn_file_actions_adddup2(&FileActions, fdSource, fd);
    17621779                        if (rcExit != 0)
    1763                             rcExit = errx(pCtx, 2, "posix_spawn_file_actions_addclose(%d) failed: %s", fd, strerror(rcExit));
     1780                            rcExit = errx(pCtx, 2, "posix_spawn_file_actions_adddup2(%d) failed: %s",
     1781                                          fdSource, fd, strerror(rcExit));
    17641782#endif
    17651783                    }
Note: See TracChangeset for help on using the changeset viewer.