Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ZSH hangs with redirection
- X-seq: zsh-workers 26077
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: ZSH hangs with redirection
- Date: Thu, 20 Nov 2008 15:56:28 -0800
- In-reply-to: <slrngibfsl.h6j.joerg@xxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <slrngibfsl.h6j.joerg@xxxxxxxxxxxx>
On Nov 20, 7:50pm, Jorg wrote:
} Subject: ZSH hangs with redirection
}
} % ( echo bla >&2 ) >&1 >/tmp/a 2>&1
} bla
} ^C
}
} I have to press ^C to get the prompt. Otherwise the process hangs. Why?
} Doing I something wrong?
Well, you've invoked a multio: >&1 >/tmp/a connects stdout to a pipe
to an "invisible" process whose job it is to read its input and write
a copy of that input to both the original stdout and to /tmp/a.
Next 2>&1 connects the standard error of the subshell to that pipe, and
last inside the subshell >&2 connects the output of echo to the same
pipe. So now you have the pipe open twice, and even though "echo bla"
exits, the pipe isn't closed, so the invisible copy job never exits.
You can force the subshell to exit by writing this:
% ( echo bla >&2 ; exit ) >&1 >/tmp/a 2>&1
Then the pipe gets closed and everything "works." I suppose it's a bug
in process handling that the subshell doesn't exit and close the pipe
once echo has finished. It's stuck here:
(gdb) where
#0 0x009107a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x00951d7c in sigsuspend () from /lib/tls/libc.so.6
#2 0x080affa3 in signal_suspend (sig=17) at ../../zsh-4.0/Src/signals.c:361
#3 0x08080c84 in zwaitjob (job=1, wait_cmd=0) at ../../zsh-4.0/Src/jobs.c:1220
#4 0x08080e5b in waitjobs () at ../../zsh-4.0/Src/jobs.c:1265
#5 0x080679e2 in execcmd (state=0xbfe78050, input=0, output=0, how=18,
last1=2) at ../../zsh-4.0/Src/exec.c:3174
#6 0x080635e1 in execpline2 (state=0xbfe78050, pcode=1027, how=18, input=0,
output=0, last1=0) at ../../zsh-4.0/Src/exec.c:1561
#7 0x080629e2 in execpline (state=0xbfe78050, slcode=22530, how=18, last1=0)
at ../../zsh-4.0/Src/exec.c:1347
#8 0x08062340 in execlist (state=0xbfe78050, dont_change_job=0, exiting=0)
at ../../zsh-4.0/Src/exec.c:1144
#9 0x08061e0b in execode (p=0xb7d9c5e0, dont_change_job=0, exiting=0)
at ../../zsh-4.0/Src/exec.c:975
#10 0x0807a553 in loop (toplevel=1, justonce=0) at ../../zsh-4.0/Src/init.c:181
#11 0x0807d2a4 in zsh_main (argc=1, argv=0xbfe78194)
at ../../zsh-4.0/Src/init.c:1406
#12 0x0804cba6 in main (argc=1, argv=0xbfe78194) at ../../zsh-4.0/Src/main.c:93
Messages sorted by:
Reverse Date,
Date,
Thread,
Author