beam2/unix: refactor api to simplify usage and allow native fd passing