MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / _hx_std_process_exit

Function _hx_std_process_exit

src/hx/libs/std/Process.cpp:460–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458**/
459#if (HXCPP_API_LEVEL > 420)
460Dynamic _hx_std_process_exit( Dynamic handle, bool block )
461{
462 vprocess *p = getProcess(handle);
463
464 hx::EnterGCFreeZone();
465 #ifdef NEKO_WINDOWS
466 {
467 DWORD rval;
468 DWORD wait = INFINITE;
469 if (!block)
470 wait = 0;
471
472 WaitForSingleObject(p->pinf.hProcess,wait);
473 hx::ExitGCFreeZone();
474
475 if( !GetExitCodeProcess(p->pinf.hProcess,&rval) && block)
476 return 0;
477 else if (!block && rval == STILL_ACTIVE)
478 return null();
479 else
480 return rval;
481 }
482 #else
483 int options=0;
484 if (!block)
485 options = WNOHANG;
486
487 int rval=0;
488 pid_t ret=-1;
489 while( (ret = waitpid(p->pid,&rval,options)) != p->pid )
490 {
491 if( errno == EINTR )
492 continue;
493
494 if (!block && ret == 0)
495 {
496 hx::ExitGCFreeZone();
497 return null();
498 }
499
500 hx::ExitGCFreeZone();
501 return 0;
502 }
503 hx::ExitGCFreeZone();
504 if( !WIFEXITED(rval) )
505 return 0;
506
507 return WEXITSTATUS(rval);
508 #endif
509}
510#else
511int _hx_std_process_exit( Dynamic handle )
512{

Callers

nothing calls this directly

Calls 4

getProcessFunction · 0.85
EnterGCFreeZoneFunction · 0.85
ExitGCFreeZoneFunction · 0.85
nullClass · 0.50

Tested by

no test coverage detected