Ignore:
Timestamp:
Sep 2, 2020, 7:25:31 PM (5 years ago)
Author:
bird
Message:

kash: refactoring forkshell(); simple stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/redir.c

    r2648 r3433  
    243243}
    244244
     245#ifdef KASH_USE_FORKSHELL2
     246struct openherechild
     247{
     248        int pip[2];
     249        size_t len;
     250};
     251static int openhere_child(shinstance *psh, union node *n, void *argp)
     252{
     253        struct openherechild args = *(struct openherechild *)argp;
     254
     255        shfile_close(&psh->fdtab, args.pip[0]);
     256        sh_signal(psh, SIGINT, SH_SIG_IGN);
     257        sh_signal(psh, SIGQUIT, SH_SIG_IGN);
     258        sh_signal(psh, SIGHUP, SH_SIG_IGN);
     259# ifdef SIGTSTP
     260        sh_signal(psh, SIGTSTP, SH_SIG_IGN);
     261# endif
     262        sh_signal(psh, SIGPIPE, SH_SIG_DFL);
     263        if (n->type == NHERE)
     264                xwrite(psh, args.pip[1], n->nhere.doc->narg.text, args.len);
     265        else
     266                expandhere(psh, n->nhere.doc, args.pip[1]);
     267        return 0;
     268}
     269
     270#endif /* KASH_USE_FORKSHELL2*/
    245271
    246272/*
     
    265291                }
    266292        }
     293#ifdef KASH_USE_FORKSHELL2
     294        {
     295                struct openherechild args;
     296                args.pip[0] = pip[0];
     297                args.pip[1] = pip[1];
     298                args.len = len;
     299                forkshell2(psh, (struct job *)NULL, (union node *)NULL, FORK_NOJOB,
     300                           openhere_child, redir, &args, sizeof(args));
     301        }
     302#else
    267303        if (forkshell(psh, (struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) {
    268304                shfile_close(&psh->fdtab, pip[0]);
     
    280316                sh__exit(psh, 0);
    281317        }
     318#endif
    282319out:
    283320        shfile_close(&psh->fdtab, pip[1]);
Note: See TracChangeset for help on using the changeset viewer.