merge stream_dup2(resource, resource) and posix_dup2(int, int) into one function accepting either stream resource or integers