1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-12 19:22:41 +00:00

Revert "Fix "/dev/null: cannot create [Bad file descriptor]" (re: feeb62d1)"

This reverts commit a72ba2cf59.

It's broken:

test coprocess begins at 2022-06-20+02:34:59
	coprocess.sh[198]: FAIL: traps when reading from cat coprocess not working
	coprocess.sh[198]: FAIL: traps when reading from /bin/cat coprocess not working
test coprocess failed at 2022-06-20+02:35:01 with exit code 2 [ 32 tests 2 errors ]

Reopens: https://github.com/ksh93/ksh/issues/483
This commit is contained in:
Martijn Dekker 2022-06-20 12:54:25 +01:00
parent a72ba2cf59
commit 80767b1fa9
4 changed files with 10 additions and 16 deletions

View file

@ -1045,9 +1045,9 @@ static Sfoff_t file_offset(int fn, char *fname)
*/
void sh_pclose(register int pv[])
{
if(pv[0] > -1)
if(pv[0]>=2)
sh_close(pv[0]);
if(pv[1] > -1)
if(pv[1]>=2)
sh_close(pv[1]);
pv[0] = pv[1] = -1;
}

View file

@ -396,11 +396,10 @@ int job_reap(register int sig)
/* check for coprocess completion */
if(pid==sh.cpid)
{
if(sh.coutpipe > -1)
sh_close(sh.coutpipe);
if(sh.cpipe[1] > -1)
sh_close(sh.cpipe[1]);
sh.coutpipe = sh.cpipe[1] = -1;
sh_close(sh.coutpipe);
sh_close(sh.cpipe[1]);
sh.cpipe[1] = -1;
sh.coutpipe = -1;
}
else if(sh.subshell)
sh_subjobcheck(pid);

View file

@ -1275,13 +1275,10 @@ static noreturn void exscript(register char *path,register char *argv[],char **e
sh.bckpid = 0;
sh.st.ioset=0;
/* clean up any cooperating processes */
if(sh.cpipe[0] > -1)
if(sh.cpipe[0]>0)
sh_pclose(sh.cpipe);
if(sh.cpid && sh.outpipe && *sh.outpipe > -1)
{
if(sh.cpid && sh.outpipe)
sh_close(*sh.outpipe);
*sh.outpipe = -1;
}
sh.cpid = 0;
if(sp=fcfile())
while(sfstack(sp,SF_POPSTACK));

View file

@ -455,10 +455,8 @@ void sh_subjobcheck(pid_t pid)
{
if(sp->cpid==pid)
{
if(sp->coutpipe > -1)
sh_close(sp->coutpipe);
if(sp->cpipe > -1)
sh_close(sp->cpipe);
sh_close(sp->coutpipe);
sh_close(sp->cpipe);
sp->coutpipe = sp->cpipe = -1;
return;
}