mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
process substitution: improve fifo error handling (re: ab5dedde
)
src/cmd/ksh93/sh/args.c: sh_argprocsub(): - Fix compiler warnings with SHOPT_DEVFD on by including "io.h". - Without SHOPT_DEVFD, the FIFO code didn't consider that libast's pathtemp(3) may also fail and return null. Add a check for this.
This commit is contained in:
parent
cea04c4a6f
commit
c709868572
1 changed files with 8 additions and 3 deletions
|
@ -36,8 +36,10 @@
|
|||
#include "FEATURE/poll"
|
||||
#if SHOPT_KIA
|
||||
# include "shlex.h"
|
||||
#endif
|
||||
#if SHOPT_KIA || SHOPT_DEVFD
|
||||
# include "io.h"
|
||||
#endif /* SHOPT_KIA */
|
||||
#endif
|
||||
#if SHOPT_PFSH
|
||||
# define PFSHOPT "P"
|
||||
#else
|
||||
|
@ -701,12 +703,15 @@ struct argnod *sh_argprocsub(Shell_t *shp,struct argnod *argp)
|
|||
sh_pipe(pv);
|
||||
#else
|
||||
pv[0] = -1;
|
||||
while((shp->fifo = pathtemp(0,0,0,"ksh.fifo",0), mkfifo(shp->fifo,0))<0)
|
||||
while(shp->fifo = pathtemp(0,0,0,"ksh.fifo",0), shp->fifo && mkfifo(shp->fifo,0)<0)
|
||||
{
|
||||
if(errno==EEXIST || errno==EACCES || errno==ENOENT || errno==ENOTDIR || errno==EROFS)
|
||||
continue; /* lost race (name conflict or tmp dir change); try again */
|
||||
errormsg(SH_DICT,ERROR_system(128),"process substitution: FIFO creation failed");
|
||||
shp->fifo = 0;
|
||||
break;
|
||||
}
|
||||
if(!shp->fifo)
|
||||
errormsg(SH_DICT,ERROR_system(128),"process substitution: FIFO creation failed");
|
||||
chmod(shp->fifo,S_IRUSR|S_IWUSR); /* mkfifo + chmod works regardless of umask */
|
||||
sfputr(shp->stk,shp->fifo,0);
|
||||
#endif /* SHOPT_DEVFD */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue