assign code to result at spawn close