Sorry, spoke too soon. The real problem has to do with output redirection.
if echo 'r /nonexist-file q' | ex works but if echo 'r /nonexist-file q' | ex > /dev/null 2>&1 hangs. Redirecting just standard output cause no problem. But there doesn't seem any output to redirect anyway...
