Quizzer
view release on metacpan or search on metacpan
exercises/compile-tcsh/tcsh-6.10.00/sh.exec.c view on Meta::CPAN
#ifdef VFORK
Vexpath = expath;
#endif /* VFORK */
v = adrof(STRpath);
if (v == 0 && expath[0] != '/' && expath[0] != '.') {
blkfree(pv);
pexerr();
}
slash = any(short2str(expath), '/');
/*
* Glob the argument list, if necessary. Otherwise trim off the quote bits.
*/
gflag = 0;
av = &t->t_dcom[1];
tglob(av);
if (gflag) {
av = globall(av);
if (av == 0) {
blkfree(pv);
setname(short2str(expath));
stderror(ERR_NAME | ERR_NOMATCH);
}
gargv = 0;
}
else
av = saveblk(av);
blkfree(t->t_dcom);
t->t_dcom = blkspl(pv, av);
xfree((ptr_t) pv);
xfree((ptr_t) av);
av = t->t_dcom;
trim(av);
if (*av == NULL || **av == '\0')
pexerr();
xechoit(av); /* Echo command if -x */
#ifdef CLOSE_ON_EXEC
/*
* Since all internal file descriptors are set to close on exec, we don't
* need to close them explicitly here. Just reorient ourselves for error
* messages.
*/
SHIN = 0;
SHOUT = 1;
SHDIAG = 2;
OLDSTD = 0;
isoutatty = isatty(SHOUT);
isdiagatty = isatty(SHDIAG);
#else
closech(); /* Close random fd's */
#endif
/*
* We must do this AFTER any possible forking (like `foo` in glob) so that
* this shell can still do subprocesses.
*/
#ifdef BSDSIGS
(void) sigsetmask((sigmask_t) 0);
#else /* BSDSIGS */
(void) sigrelse(SIGINT);
(void) sigrelse(SIGCHLD);
#endif /* BSDSIGS */
/*
* If no path, no words in path, or a / in the filename then restrict the
* command search.
*/
if (v == 0 || v->vec[0] == 0 || slash)
pv = justabs;
else
pv = v->vec;
sav = Strspl(STRslash, *av);/* / command name for postpending */
#ifdef VFORK
Vsav = sav;
#endif /* VFORK */
hashval = havhash ? hashname(*av) : 0;
i = 0;
#ifdef VFORK
hits++;
#endif /* VFORK */
do {
/*
* Try to save time by looking at the hash table for where this command
* could be. If we are doing delayed hashing, then we put the names in
* one at a time, as the user enters them. This is kinda like Korn
* Shell's "tracked aliases".
*/
if (!slash && ABSOLUTEP(pv[0]) && havhash) {
#ifdef FASTHASH
if (!bit(hashval, i))
goto cont;
#else /* OLDHASH */
int hashval1 = hash(hashval, i);
if (!bit(xhash, hashval1))
goto cont;
#endif /* FASTHASH */
}
if (pv[0][0] == 0 || eq(pv[0], STRdot)) /* don't make ./xxx */
{
#ifdef COHERENT
if (t->t_dflg & F_AMPERSAND) {
# ifdef JOBDEBUG
xprintf("set SIGINT to SIG_IGN\n");
xprintf("set SIGQUIT to SIG_DFL\n");
# endif /* JOBDEBUG */
(void) signal(SIGINT,SIG_IGN); /* may not be necessary */
(void) signal(SIGQUIT,SIG_DFL);
}
if (gointr && eq(gointr, STRminus)) {
# ifdef JOBDEBUG
xprintf("set SIGINT to SIG_IGN\n");
xprintf("set SIGQUIT to SIG_IGN\n");
# endif /* JOBDEBUG */
(void) signal(SIGINT,SIG_IGN); /* may not be necessary */
(void) signal(SIGQUIT,SIG_IGN);
( run in 1.217 second using v1.01-cache-2.11-cpan-6736b670a1e )