Move API error code handling
Make process_spawn, file_open and pipe_create_ easier to use internally