Handle fd argument consistently

We always use long and cast it appropriately later, that seems to work
in all platforms