fd might be stdin here