Re: dwww: cat and file (pipe race condition)
email@example.com (Ulf Jaenicke-Roessler) writes:
> It seems, that the problem only occurs with longer (more than 10000 chars)
> files. Looking for the cause of this problem, I found that the line
> "$decompress $file | file -b - | magic2mime" in dwww-convert is responsible.
Well, if I do a
$process | file -b - | magic2mime
where "$process" is anything that produces a large amount of output
slowly, then the process is killed by a SIGPIPE in short order.
If, however, I do:
$process | (file -b -; cat >/dev/null) | magic2mime
then it seems that the process runs happily (that is, no signals) to
However, this may not be what you really would want. (Since waiting
for process to finish could cause the webserver to time out) What
your problem may be is that somehow the cat process is not receiving
the SIGPIPE signal; I would then try to see about rewriting the dwww
script so that it does. (I'm not sure how to do this, since the bash
manpage seems to imply that one can't change which signals are ignored
by the shell).
You could test whether cat is ignoring the SIGPIPE signal by sending
the dangling cat process such a signal and seeing if it dies.