Don't read from stdout in hijack unless attached. Fixes #1503