import: fix crashes when redirecting to a pipe