N_NIMCALL(void, socketerror_515025)(Socketimpl514407* socket, NI err, NIM_BOOL async, NI32 lasterror) { { { NIM_BOOL LOC3; NI32 laste; LOC3 = 0; LOC3 = (err == ((NI) -1)); if (!(LOC3)) goto LA4; LOC3 = NIM_TRUE; LA4: ; if (!LOC3) goto LA5; { if (!(((NI) (lasterror)) == ((NI) -1))) goto LA9; laste = getsocketerror_515001(socket); } goto LA7; LA9: ; { laste = lasterror; } LA7: ; { if (!async) goto LA14; { NIM_BOOL LOC18; LOC18 = 0; LOC18 = (laste == EAGAIN); if (LOC18) goto LA19; LOC18 = (laste == EWOULDBLOCK); LA19: ; if (!LOC18) goto LA20; goto BeforeRet; } goto LA16; LA20: ; { raiseoserror_117009(laste); } LA16: ; } goto LA12; LA14: ; { raiseoserror_117009(laste); } LA12: ; } LA5: ; }BeforeRet: ; }
N_NIMCALL(void, acceptaddr_515813)(Socketimpl514407* server, Socketimpl514407** client, NimStringDesc** address, NU8 flags) { struct sockaddr_in sockaddress; socklen_t addrlen; int sock; memset((void*)(&sockaddress), 0, sizeof(sockaddress)); addrlen = ((socklen_t) (((NI)sizeof(struct sockaddr_in)))); sock = accept((*server).fd, ((struct sockaddr*) ((&sockaddress))), (&addrlen)); { NI32 err; if (!(sock == osinvalidsocket_509654)) goto LA3; err = oslasterror_117033(); { NIM_BOOL LOC7; LOC7 = 0; LOC7 = isdisconnectionerror_514481(flags, err); if (!LOC7) goto LA8; acceptaddr_515813(server, client, address, flags); } LA8: ; raiseoserror_117009(err); } goto LA1; LA3: ; { NCSTRING LOC11; (*(*client)).fd = sock; (*(*client)).isbuffered = (*server).isbuffered; LOC11 = 0; LOC11 = inet_ntoa(sockaddress.sin_addr); unsureAsgnRef((void**) (&(*address)), cstrToNimstr(LOC11)); } LA1: ; }
N_NIMCALL(NI, nospwaitForExit)(Processobj143402* p, NI timeout) { NI result; { result = 0; { if (!!(((*p).exitcode == ((NI32) -3)))) goto LA3; result = ((NI) ((*p).exitcode)); goto BeforeRet; } LA3: ; { pid_t LOC7; NI32 LOC10; LOC7 = 0; LOC7 = waitpid((*p).id, (&(*p).exitcode), ((int) 0)); if (!(LOC7 < ((NI) 0))) goto LA8; (*p).exitcode = ((int) -3); LOC10 = 0; LOC10 = oslasterror_117033(); raiseoserror_117009(LOC10); } LA8: ; result = (NI)((NU32)(((NI) ((*p).exitcode))) >> (NU32)(((NI) 8))); }BeforeRet: ; return result; }
N_NIMCALL(void*, mapmem_231219)(Memfile231208* m, NU8 mode, NI mappedsize, NI offset) { void* result; NIM_BOOL readonly; int LOC5; NI32 LOC11; nimfr("mapMem", "memfiles.nim") result = 0; nimln(41, "memfiles.nim"); readonly = (mode == ((NU8) 0)); nimln(53, "memfiles.nim"); { if (!!((((NI) 0) < mappedsize))) goto LA3; failedassertimpl_87217(((NimStringDesc*) &TMP3724)); } LA3: ; nimln(54, "memfiles.nim"); LOC5 = 0; nimln(57, "memfiles.nim"); { if (!readonly) goto LA8; LOC5 = PROT_READ; } goto LA6; LA8: ; { LOC5 = (NI32)(PROT_READ | PROT_WRITE); } LA6: ; LOC11 = 0; nimln(58, "memfiles.nim"); { if (!readonly) goto LA14; LOC11 = (NI32)(MAP_PRIVATE | Mappopulate_109138); } goto LA12; LA14: ; { LOC11 = (NI32)(MAP_SHARED | Mappopulate_109138); } LA12: ; result = mmap(NIM_NIL, mappedsize, LOC5, LOC11, (*m).handle, ((off_t) (offset))); nimln(60, "memfiles.nim"); { NI32 LOC21; if (!(result == ((void*) (MAP_FAILED)))) goto LA19; nimln(61, "memfiles.nim"); LOC21 = 0; LOC21 = oslasterror_117033(); raiseoserror_117009(LOC21); } LA19: ; popFrame(); return result; }
N_NIMCALL(void, bindaddr_515620)(Socketimpl514407* socket, NU16 port, NimStringDesc* address) { { struct sockaddr_in name; if (!((address) && (address)->Sup.len == 0)) goto LA3; memset((void*)(&name), 0, sizeof(name)); name.sin_family = toint_509829(((NU8) 2)); name.sin_port = htons_511017(((NI16) (port))); name.sin_addr.s_addr = htonl_511007(INADDR_ANY); { int LOC7; NI32 LOC10; LOC7 = 0; LOC7 = bindaddr_510214((*socket).fd, ((struct sockaddr*) ((&name))), ((socklen_t) (((NI)sizeof(struct sockaddr_in))))); if (!(LOC7 < ((NI32) 0))) goto LA8; LOC10 = 0; LOC10 = oslasterror_117033(); raiseoserror_117009(LOC10); } LA8: ; } goto LA1; LA3: ; { struct addrinfo* ailist; ailist = getaddrinfo_510408(address, port, ((NU8) 2), ((NU8) 1), ((NU8) 6)); { int LOC14; NI32 LOC17; LOC14 = 0; LOC14 = bindaddr_510214((*socket).fd, (*ailist).ai_addr, (*ailist).ai_addrlen); if (!(LOC14 < ((NI32) 0))) goto LA15; dealloc_510621(ailist); LOC17 = 0; LOC17 = oslasterror_117033(); raiseoserror_117009(LOC17); } LA15: ; dealloc_510621(ailist); } LA1: ; }
N_NIMCALL(void, listen_515610)(Socketimpl514407* socket, int backlog) { { int LOC3; NI32 LOC6; LOC3 = 0; LOC3 = listen_510227((*socket).fd, backlog); if (!(LOC3 < ((NI32) 0))) goto LA4; LOC6 = 0; LOC6 = oslasterror_117033(); raiseoserror_117009(LOC6); } LA4: ; }
static N_INLINE(void, setcurrentdir_119207)(NimStringDesc* newdir) { { int LOC3; NI32 LOC6; LOC3 = 0; LOC3 = chdir(newdir->data); if (!!((LOC3 == ((NI32) 0)))) goto LA4; LOC6 = 0; LOC6 = oslasterror_117033(); raiseoserror_117009(LOC6); } LA4: ; }
N_NIMCALL(void, unmapmem_231608)(Memfile231208* f, void* p, NI size) { nimfr("unmapMem", "memfiles.nim") nimln(72, "memfiles.nim"); { int LOC3; NI32 LOC6; LOC3 = 0; LOC3 = munmap(p, size); if (!!((LOC3 == ((NI32) 0)))) goto LA4; LOC6 = 0; LOC6 = oslasterror_117033(); raiseoserror_117009(LOC6); } LA4: ; popFrame(); }
N_NIMCALL(Socketimpl514407*, newsocket_514830)(NU8 domain, NU8 typ, NU8 protocol, NIM_BOOL buffered) { Socketimpl514407* result; int fd; result = 0; fd = newrawsocket_510004(domain, typ, protocol); { NI32 LOC5; if (!(fd == osinvalidsocket_509654)) goto LA3; LOC5 = 0; LOC5 = oslasterror_117033(); raiseoserror_117009(LOC5); } LA3: ; result = newsocket_514708(fd, buffered); return result; }
N_NIMCALL(void, close_232248)(Memfile231208* f) { NIM_BOOL error; NI32 lasterr; nimfr("close", "memfiles.nim") nimln(222, "memfiles.nim"); error = NIM_FALSE; lasterr = 0; nimln(232, "memfiles.nim"); { int LOC5; NIM_BOOL LOC6; int LOC7; if (!!(((*f).handle == ((NI32) 0)))) goto LA3; nimln(233, "memfiles.nim"); LOC5 = 0; LOC5 = munmap((*f).mem, (*f).size); error = !((LOC5 == ((NI32) 0))); nimln(234, "memfiles.nim"); lasterr = oslasterror_117033(); nimln(235, "memfiles.nim"); LOC6 = 0; LOC7 = 0; LOC7 = close((*f).handle); LOC6 = !((LOC7 == ((NI32) 0))); if (LOC6) goto LA8; LOC6 = error; LA8: ; error = LOC6; } LA3: ; nimln(237, "memfiles.nim"); (*f).size = ((NI) 0); nimln(238, "memfiles.nim"); (*f).mem = NIM_NIL; nimln(244, "memfiles.nim"); (*f).handle = ((int) 0); nimln(246, "memfiles.nim"); { if (!error) goto LA11; raiseoserror_117009(lasterr); } LA11: ; popFrame(); }
N_NIMCALL(void, createstream_146441)(Streamobj138027** stream, int* handle, NU8 filemode) { FILE* f; Filestreamobj138692* LOC7; f = 0; { NIM_BOOL LOC3; NI32 LOC6; LOC3 = 0; LOC3 = open_13411(&f, (*handle), filemode); if (!!(LOC3)) goto LA4; LOC6 = 0; LOC6 = oslasterror_117033(); raiseoserror_117009(LOC6); } LA4: ; LOC7 = 0; LOC7 = newfilestream_138758(f); unsureAsgnRef((void**) (&(*stream)), &LOC7->Sup); }
N_NIMCALL(Memfile231208, open_231807)(NimStringDesc* filename, NU8 mode, NI mappedsize, NI offset, NI newfilesize) { Memfile231208 result; NIM_BOOL readonly; int flags; int LOC59; NI32 LOC65; nimfr("open", "memfiles.nim") memset((void*)(&result), 0, sizeof(result)); nimln(96, "memfiles.nim"); { NIM_BOOL LOC3; LOC3 = 0; LOC3 = (newfilesize == ((NI) -1)); if (LOC3) goto LA4; LOC3 = !((mode == ((NU8) 0))); LA4: ; if (!!(LOC3)) goto LA5; failedassertimpl_87217(((NimStringDesc*) &TMP3725)); } LA5: ; nimln(97, "memfiles.nim"); readonly = (mode == ((NU8) 0)); nimln(178, "memfiles.nim"); { if (!readonly) goto LA9; flags = O_RDONLY; } goto LA7; LA9: ; { flags = O_RDWR; } LA7: ; nimln(180, "memfiles.nim"); { NI32 permissionsmode; if (!!((newfilesize == ((NI) -1)))) goto LA14; nimln(181, "memfiles.nim"); flags = (NI32)((NI32)(flags | O_CREAT) | O_TRUNC); nimln(182, "memfiles.nim"); permissionsmode = (NI32)(S_IRUSR | S_IWUSR); nimln(183, "memfiles.nim"); result.handle = open(filename->data, flags, permissionsmode); } goto LA12; LA14: ; { nimln(185, "memfiles.nim"); result.handle = open(filename->data, flags); } LA12: ; nimln(187, "memfiles.nim"); { NI32 LOC26; if (!(result.handle == ((NI32) -1))) goto LA19; nimln(100, "memfiles.nim"); result.mem = NIM_NIL; nimln(101, "memfiles.nim"); result.size = ((NI) 0); nimln(175, "memfiles.nim"); { int LOC25; if (!!((result.handle == ((NI32) 0)))) goto LA23; LOC25 = 0; LOC25 = close(result.handle); } LA23: ; nimln(176, "memfiles.nim"); nimln(190, "memfiles.nim"); LOC26 = 0; LOC26 = oslasterror_117033(); raiseoserror_117009(LOC26); } LA19: ; nimln(192, "memfiles.nim"); { if (!!((newfilesize == ((NI) -1)))) goto LA29; nimln(193, "memfiles.nim"); { int LOC33; NI32 LOC41; LOC33 = 0; LOC33 = ftruncate(result.handle, ((off_t) (newfilesize))); if (!(LOC33 == ((NI32) -1))) goto LA34; nimln(100, "memfiles.nim"); result.mem = NIM_NIL; nimln(101, "memfiles.nim"); result.size = ((NI) 0); nimln(175, "memfiles.nim"); { int LOC40; if (!!((result.handle == ((NI32) 0)))) goto LA38; LOC40 = 0; LOC40 = close(result.handle); } LA38: ; nimln(176, "memfiles.nim"); nimln(194, "memfiles.nim"); LOC41 = 0; LOC41 = oslasterror_117033(); raiseoserror_117009(LOC41); } LA34: ; } LA29: ; nimln(196, "memfiles.nim"); { if (!!((mappedsize == ((NI) -1)))) goto LA44; nimln(197, "memfiles.nim"); result.size = mappedsize; } goto LA42; LA44: ; { struct stat stat; memset((void*)(&stat), 0, sizeof(stat)); nimln(200, "memfiles.nim"); { int LOC49; LOC49 = 0; LOC49 = fstat(result.handle, (&stat)); if (!!((LOC49 == ((NI32) -1)))) goto LA50; nimln(203, "memfiles.nim"); result.size = ((NI)chckRange64(stat.st_size, ((NI) (-2147483647 -1)), ((NI) 2147483647))); } goto LA47; LA50: ; { NI32 LOC58; nimln(100, "memfiles.nim"); result.mem = NIM_NIL; nimln(101, "memfiles.nim"); result.size = ((NI) 0); nimln(175, "memfiles.nim"); { int LOC57; if (!!((result.handle == ((NI32) 0)))) goto LA55; LOC57 = 0; LOC57 = close(result.handle); } LA55: ; nimln(176, "memfiles.nim"); nimln(205, "memfiles.nim"); LOC58 = 0; LOC58 = oslasterror_117033(); raiseoserror_117009(LOC58); } LA47: ; } LA42: ; nimln(207, "memfiles.nim"); LOC59 = 0; nimln(210, "memfiles.nim"); { if (!readonly) goto LA62; LOC59 = PROT_READ; } goto LA60; LA62: ; { LOC59 = (NI32)(PROT_READ | PROT_WRITE); } LA60: ; LOC65 = 0; nimln(211, "memfiles.nim"); { if (!readonly) goto LA68; LOC65 = (NI32)(MAP_PRIVATE | Mappopulate_109138); } goto LA66; LA68: ; { LOC65 = (NI32)(MAP_SHARED | Mappopulate_109138); } LA66: ; result.mem = mmap(NIM_NIL, result.size, LOC59, LOC65, result.handle, ((off_t) (offset))); nimln(215, "memfiles.nim"); { NI32 LOC80; if (!(result.mem == ((void*) (MAP_FAILED)))) goto LA73; nimln(100, "memfiles.nim"); result.mem = NIM_NIL; nimln(101, "memfiles.nim"); result.size = ((NI) 0); nimln(175, "memfiles.nim"); { int LOC79; if (!!((result.handle == ((NI32) 0)))) goto LA77; LOC79 = 0; LOC79 = close(result.handle); } LA77: ; nimln(176, "memfiles.nim"); nimln(216, "memfiles.nim"); LOC80 = 0; LOC80 = oslasterror_117033(); raiseoserror_117009(LOC80); } LA73: ; popFrame(); return result; }
N_NIMCALL(NI, waitfor_517818)(Socketimpl514407* socket, NF* waited, NI timeout, NI size, NimStringDesc* funcname) { NI result; { result = 0; result = ((NI) 1); { if (!(size <= ((NI) 0))) goto LA3; } LA3: ; { if (!(timeout == ((NI) -1))) goto LA7; result = size; goto BeforeRet; } LA7: ; { NIM_BOOL LOC11; NIM_BOOL LOC12; LOC11 = 0; LOC12 = 0; LOC12 = (*socket).isbuffered; if (!(LOC12)) goto LA13; LOC12 = !(((*socket).isbufferedU.S1.buflen == ((NI) 0))); LA13: ; LOC11 = LOC12; if (!(LOC11)) goto LA14; LOC11 = !(((*socket).isbufferedU.S1.buflen == (*socket).isbufferedU.S1.currpos)); LA14: ; if (!LOC11) goto LA15; result = (NI)((*socket).isbufferedU.S1.buflen - (*socket).isbufferedU.S1.currpos); result = ((result <= size) ? result : size); } goto LA9; LA15: ; { NF starttime; NI selret; NF LOC33; { Timeouterror514415* e_518013; NimStringDesc* LOC22; if (!((NI)(timeout - ((NI) (((NF)((*waited)) * (NF)(1.0000000000000000e+03))))) < ((NI) 1))) goto LA20; e_518013 = 0; e_518013 = (Timeouterror514415*) newObj((&NTI518014), sizeof(Timeouterror514415)); (*e_518013).Sup.Sup.m_type = (&NTI514415); LOC22 = 0; LOC22 = rawNewString(funcname->Sup.len + 21); appendString(LOC22, ((NimStringDesc*) &TMP4997)); appendString(LOC22, funcname); appendString(LOC22, ((NimStringDesc*) &TMP4998)); asgnRefNoCycle((void**) (&(*e_518013).Sup.message), LOC22); raiseException((Exception*)e_518013, "TimeoutError"); } LA20: ; starttime = ntepochTime(); selret = select_517207(socket, (NI)(timeout - ((NI) (((NF)((*waited)) * (NF)(1.0000000000000000e+03)))))); { NI32 LOC27; if (!(selret < ((NI) 0))) goto LA25; LOC27 = 0; LOC27 = oslasterror_117033(); raiseoserror_117009(LOC27); } LA25: ; { Timeouterror514415* e_518206; NimStringDesc* LOC32; if (!!((selret == ((NI) 1)))) goto LA30; e_518206 = 0; e_518206 = (Timeouterror514415*) newObj((&NTI518014), sizeof(Timeouterror514415)); (*e_518206).Sup.Sup.m_type = (&NTI514415); LOC32 = 0; LOC32 = rawNewString(funcname->Sup.len + 21); appendString(LOC32, ((NimStringDesc*) &TMP4997)); appendString(LOC32, funcname); appendString(LOC32, ((NimStringDesc*) &TMP4998)); asgnRefNoCycle((void**) (&(*e_518206).Sup.message), LOC32); raiseException((Exception*)e_518206, "TimeoutError"); } LA30: ; LOC33 = 0; LOC33 = ntepochTime(); HEX2BHEX3D_103688(waited, ((NF)(LOC33) - (NF)(starttime))); } LA9: ; }BeforeRet: ; return result; }
N_NIMCALL(Processobj143402*, nospstartProcess)(NimStringDesc* command, NimStringDesc* workingdir, NimStringDesc** args, NI argsLen0, Stringtableobj134012* env, NU8 options) { Processobj143402* result; TY145025 pstdin; TY145025 pstdout; TY145025 pstderr; NimStringDesc* syscommand; TY122208* sysargsraw; pid_t volatile pid; NCSTRING* sysargs; TSafePoint TMP2889; result = 0; memset((void*)pstdin, 0, sizeof(pstdin)); memset((void*)pstdout, 0, sizeof(pstdout)); memset((void*)pstderr, 0, sizeof(pstderr)); result = (Processobj143402*) newObj((&NTI143404), sizeof(Processobj143402)); (*result).Sup.m_type = (&NTI143402); (*result).exitcode = ((int) -3); { if (!!(((options &(1<<((((NU8) 4))&7)))!=0))) goto LA3; { NIM_BOOL LOC7; NIM_BOOL LOC8; int LOC9; int LOC11; int LOC13; NI32 LOC16; LOC7 = 0; LOC8 = 0; LOC9 = 0; LOC9 = pipe(pstdin); LOC8 = !((LOC9 == ((NI32) 0))); if (LOC8) goto LA10; LOC11 = 0; LOC11 = pipe(pstdout); LOC8 = !((LOC11 == ((NI32) 0))); LA10: ; LOC7 = LOC8; if (LOC7) goto LA12; LOC13 = 0; LOC13 = pipe(pstderr); LOC7 = !((LOC13 == ((NI32) 0))); LA12: ; if (!LOC7) goto LA14; LOC16 = 0; LOC16 = oslasterror_117033(); raiseoserror_117009(LOC16); } LA14: ; } LA3: ; syscommand = 0; sysargsraw = 0; { TY176063 LOC21; NimStringDesc* LOC22; NimStringDesc* LOC23; NimStringDesc* LOC24; if (!((options &(1<<((((NU8) 2))&7)))!=0)) goto LA19; syscommand = copyString(((NimStringDesc*) &TMP2887)); sysargsraw = (TY122208*) newSeq((&NTI122208), 3); memset((void*)LOC21, 0, sizeof(LOC21)); LOC21[0] = copyString(syscommand); LOC21[1] = copyString(((NimStringDesc*) &TMP2888)); LOC21[2] = copyString(command); LOC22 = 0; LOC22 = sysargsraw->data[0]; sysargsraw->data[0] = copyStringRC1(LOC21[0]); if (LOC22) nimGCunrefNoCycle(LOC22); LOC23 = 0; LOC23 = sysargsraw->data[1]; sysargsraw->data[1] = copyStringRC1(LOC21[1]); if (LOC23) nimGCunrefNoCycle(LOC23); LOC24 = 0; LOC24 = sysargsraw->data[2]; sysargsraw->data[2] = copyStringRC1(LOC21[2]); if (LOC24) nimGCunrefNoCycle(LOC24); } goto LA17; LA19: ; { TY164580 LOC26; NimStringDesc* LOC27; syscommand = copyString(command); sysargsraw = (TY122208*) newSeq((&NTI122208), 1); memset((void*)LOC26, 0, sizeof(LOC26)); LOC26[0] = copyString(command); LOC27 = 0; LOC27 = sysargsraw->data[0]; sysargsraw->data[0] = copyStringRC1(LOC26[0]); if (LOC27) nimGCunrefNoCycle(LOC27); { NimStringDesc* arg_145224; NI i_145481; arg_145224 = 0; i_145481 = ((NI) 0); { while (1) { NimStringDesc* LOC31; if (!(i_145481 < argsLen0)) goto LA30; arg_145224 = args[i_145481]; sysargsraw = (TY122208*) incrSeq(&(sysargsraw)->Sup, sizeof(NimStringDesc*)); LOC31 = 0; LOC31 = sysargsraw->data[sysargsraw->Sup.len-1]; sysargsraw->data[sysargsraw->Sup.len-1] = copyStringRC1(arg_145224); if (LOC31) nimGCunrefNoCycle(LOC31); i_145481 += ((NI) 1); } LA30: ; } } } LA17: ; pid = 0; sysargs = alloccstringarray_14201(sysargsraw->data, sysargsraw->Sup.len); pushSafePoint(&TMP2889); TMP2889.status = _setjmp(TMP2889.context); if (TMP2889.status == 0) { NCSTRING* sysenv; TSafePoint TMP2891; { if (!(env == NIM_NIL)) goto LA35; sysenv = envtocstringarray_144854(); } goto LA33; LA35: ; { sysenv = envtocstringarray_144806(env); } LA33: ; pushSafePoint(&TMP2891); TMP2891.status = _setjmp(TMP2891.context); if (TMP2891.status == 0) { Tstartprocessdata144948 data; memset((void*)(&data), 0, sizeof(data)); data.syscommand = syscommand->data; data.sysargs = sysargs; data.sysenv = sysenv; memcpy((void*)data.pstdin, (NIM_CONST void*)pstdin, sizeof(data.pstdin)); memcpy((void*)data.pstdout, (NIM_CONST void*)pstdout, sizeof(data.pstdout)); memcpy((void*)data.pstderr, (NIM_CONST void*)pstderr, sizeof(data.pstderr)); data.optionpoparentstreams = ((options &(1<<((((NU8) 4))&7)))!=0); data.optionpousepath = ((options &(1<<((((NU8) 1))&7)))!=0); data.optionpostderrtostdout = ((options &(1<<((((NU8) 3))&7)))!=0); data.workingdir = workingdir->data; pid = startprocessauxspawn_145001((&data)); { NimStringDesc* LOC43; if (!((options &(1<<((((NU8) 0))&7)))!=0)) goto LA41; LOC43 = 0; LOC43 = nsuJoinSep(args, argsLen0, ((NimStringDesc*) &TMP2892)); printf("%s%s%s\012", command? (command)->data:"nil", ((NimStringDesc*) &TMP2892)? (((NimStringDesc*) &TMP2892))->data:"nil", LOC43? (LOC43)->data:"nil"); } LA41: ; (*result).id = pid; { if (!((options &(1<<((((NU8) 4))&7)))!=0)) goto LA46; (*result).inhandle = ((int) 0); (*result).outhandle = ((int) 1); { if (!((options &(1<<((((NU8) 3))&7)))!=0)) goto LA50; (*result).errhandle = (*result).outhandle; } goto LA48; LA50: ; { (*result).errhandle = ((int) 2); } LA48: ; } goto LA44; LA46: ; { int LOC60; int LOC61; int LOC62; (*result).inhandle = pstdin[(((NI) 1))- 0]; (*result).outhandle = pstdout[(((NI) 0))- 0]; { int LOC58; if (!((options &(1<<((((NU8) 3))&7)))!=0)) goto LA56; (*result).errhandle = (*result).outhandle; LOC58 = 0; LOC58 = close(pstderr[(((NI) 0))- 0]); } goto LA54; LA56: ; { (*result).errhandle = pstderr[(((NI) 0))- 0]; } LA54: ; LOC60 = 0; LOC60 = close(pstderr[(((NI) 1))- 0]); LOC61 = 0; LOC61 = close(pstdin[(((NI) 0))- 0]); LOC62 = 0; LOC62 = close(pstdout[(((NI) 1))- 0]); } LA44: ; popSafePoint(); } else { popSafePoint(); } { dealloccstringarray_14450(sysenv); } if (TMP2891.status != 0) reraiseException(); popSafePoint(); } else { popSafePoint(); } { dealloccstringarray_14450(sysargs); } if (TMP2889.status != 0) reraiseException(); return result; }
N_NIMCALL(pid_t, startprocessauxspawn_145001)(Tstartprocessdata144948* data) { pid_t result; posix_spawnattr_t attr; posix_spawn_file_actions_t fops; sigset_t mask; int res; pid_t pid; int LOC98; int LOC99; { result = 0; memset((void*)(&attr), 0, sizeof(attr)); memset((void*)(&fops), 0, sizeof(fops)); { int LOC3; NI32 LOC6; LOC3 = 0; LOC3 = posix_spawn_file_actions_init((&fops)); if (!!((LOC3 == ((NI32) 0)))) goto LA4; LOC6 = 0; LOC6 = oslasterror_117033(); raiseoserror_117009(LOC6); } LA4: ; { int LOC9; NI32 LOC12; LOC9 = 0; LOC9 = posix_spawnattr_init((&attr)); if (!!((LOC9 == ((NI32) 0)))) goto LA10; LOC12 = 0; LOC12 = oslasterror_117033(); raiseoserror_117009(LOC12); } LA10: ; memset((void*)(&mask), 0, sizeof(mask)); { int LOC15; NI32 LOC18; LOC15 = 0; LOC15 = sigemptyset((&mask)); if (!!((LOC15 == ((NI32) 0)))) goto LA16; LOC18 = 0; LOC18 = oslasterror_117033(); raiseoserror_117009(LOC18); } LA16: ; { int LOC21; NI32 LOC24; LOC21 = 0; LOC21 = posix_spawnattr_setsigmask((&attr), (&mask)); if (!!((LOC21 == ((NI32) 0)))) goto LA22; LOC24 = 0; LOC24 = oslasterror_117033(); raiseoserror_117009(LOC24); } LA22: ; { int LOC27; NI32 LOC30; LOC27 = 0; LOC27 = posix_spawnattr_setpgroup((&attr), ((pid_t) 0)); if (!!((LOC27 == ((NI32) 0)))) goto LA28; LOC30 = 0; LOC30 = oslasterror_117033(); raiseoserror_117009(LOC30); } LA28: ; { int LOC33; NI32 LOC36; LOC33 = 0; LOC33 = posix_spawnattr_setflags((&attr), (NI32)((NI32)(((int) 0) | POSIX_SPAWN_SETSIGMASK) | POSIX_SPAWN_SETPGROUP)); if (!!((LOC33 == ((NI32) 0)))) goto LA34; LOC36 = 0; LOC36 = oslasterror_117033(); raiseoserror_117009(LOC36); } LA34: ; { if (!!((*data).optionpoparentstreams)) goto LA39; { int LOC43; NI32 LOC46; LOC43 = 0; LOC43 = posix_spawn_file_actions_addclose((&fops), (*data).pstdin[(((NI) 1))- 0]); if (!!((LOC43 == ((NI32) 0)))) goto LA44; LOC46 = 0; LOC46 = oslasterror_117033(); raiseoserror_117009(LOC46); } LA44: ; { int LOC49; NI32 LOC52; LOC49 = 0; LOC49 = posix_spawn_file_actions_adddup2((&fops), (*data).pstdin[(((NI) 0))- 0], ((int) 0)); if (!!((LOC49 == ((NI32) 0)))) goto LA50; LOC52 = 0; LOC52 = oslasterror_117033(); raiseoserror_117009(LOC52); } LA50: ; { int LOC55; NI32 LOC58; LOC55 = 0; LOC55 = posix_spawn_file_actions_addclose((&fops), (*data).pstdout[(((NI) 0))- 0]); if (!!((LOC55 == ((NI32) 0)))) goto LA56; LOC58 = 0; LOC58 = oslasterror_117033(); raiseoserror_117009(LOC58); } LA56: ; { int LOC61; NI32 LOC64; LOC61 = 0; LOC61 = posix_spawn_file_actions_adddup2((&fops), (*data).pstdout[(((NI) 1))- 0], ((int) 1)); if (!!((LOC61 == ((NI32) 0)))) goto LA62; LOC64 = 0; LOC64 = oslasterror_117033(); raiseoserror_117009(LOC64); } LA62: ; { int LOC67; NI32 LOC70; LOC67 = 0; LOC67 = posix_spawn_file_actions_addclose((&fops), (*data).pstderr[(((NI) 0))- 0]); if (!!((LOC67 == ((NI32) 0)))) goto LA68; LOC70 = 0; LOC70 = oslasterror_117033(); raiseoserror_117009(LOC70); } LA68: ; { if (!(*data).optionpostderrtostdout) goto LA73; { int LOC77; NI32 LOC80; LOC77 = 0; LOC77 = posix_spawn_file_actions_adddup2((&fops), (*data).pstdout[(((NI) 1))- 0], ((int) 2)); if (!!((LOC77 == ((NI32) 0)))) goto LA78; LOC80 = 0; LOC80 = oslasterror_117033(); raiseoserror_117009(LOC80); } LA78: ; } goto LA71; LA73: ; { { int LOC84; NI32 LOC87; LOC84 = 0; LOC84 = posix_spawn_file_actions_adddup2((&fops), (*data).pstderr[(((NI) 1))- 0], ((int) 2)); if (!!((LOC84 == ((NI32) 0)))) goto LA85; LOC87 = 0; LOC87 = oslasterror_117033(); raiseoserror_117009(LOC87); } LA85: ; } LA71: ; } LA39: ; res = 0; { NimStringDesc* LOC92; if (!(((NI) 0) < ((*data).workingdir ? strlen((*data).workingdir) : 0))) goto LA90; LOC92 = 0; LOC92 = cstrToNimstr((*data).workingdir); setcurrentdir_119207(LOC92); } LA90: ; pid = 0; { if (!(*data).optionpousepath) goto LA95; res = posix_spawnp((&pid), (*data).syscommand, (&fops), (&attr), (*data).sysargs, (*data).sysenv); } goto LA93; LA95: ; { res = posix_spawn((&pid), (*data).syscommand, (&fops), (&attr), (*data).sysargs, (*data).sysenv); } LA93: ; LOC98 = 0; LOC98 = posix_spawn_file_actions_destroy((&fops)); LOC99 = 0; LOC99 = posix_spawnattr_destroy((&attr)); { NI32 LOC104; if (!!((res == ((NI32) 0)))) goto LA102; LOC104 = 0; LOC104 = oslasterror_117033(); raiseoserror_117009(LOC104); } LA102: ; result = pid; goto BeforeRet; }BeforeRet: ; return result; }