MCPcopy Create free account
hub / github.com/Kitware/CMake / kwsysProcess_Delete

Function kwsysProcess_Delete

Source/kwsys/ProcessWin32.c:456–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454}
455
456void kwsysProcess_Delete(kwsysProcess* cp)
457{
458 int i;
459
460 /* Make sure we have an instance. */
461 if (!cp) {
462 return;
463 }
464
465 /* If the process is executing, wait for it to finish. */
466 if (cp->State == kwsysProcess_State_Executing) {
467 if (cp->Detached) {
468 kwsysProcess_Disown(cp);
469 } else {
470 kwsysProcess_WaitForExit(cp, 0);
471 }
472 }
473
474 /* We are deleting the kwsysProcess instance. */
475 cp->Deleting = 1;
476
477 /* Terminate each of the threads. */
478 for (i = 0; i < KWSYSPE_PIPE_COUNT; ++i) {
479 /* Terminate this reading thread. */
480 if (cp->Pipe[i].Reader.Thread) {
481 /* Signal the thread we are ready for it. It will terminate
482 immediately since Deleting is set. */
483 ReleaseSemaphore(cp->Pipe[i].Reader.Ready, 1, 0);
484
485 /* Wait for the thread to exit. */
486 WaitForSingleObject(cp->Pipe[i].Reader.Thread, INFINITE);
487
488 /* Close the handle to the thread. */
489 kwsysProcessCleanupHandle(&cp->Pipe[i].Reader.Thread);
490 }
491
492 /* Terminate this waking thread. */
493 if (cp->Pipe[i].Waker.Thread) {
494 /* Signal the thread we are ready for it. It will terminate
495 immediately since Deleting is set. */
496 ReleaseSemaphore(cp->Pipe[i].Waker.Ready, 1, 0);
497
498 /* Wait for the thread to exit. */
499 WaitForSingleObject(cp->Pipe[i].Waker.Thread, INFINITE);
500
501 /* Close the handle to the thread. */
502 kwsysProcessCleanupHandle(&cp->Pipe[i].Waker.Thread);
503 }
504
505 /* Cleanup the pipe's semaphores. */
506 kwsysProcessCleanupHandle(&cp->Pipe[i].Reader.Ready);
507 kwsysProcessCleanupHandle(&cp->Pipe[i].Reader.Go);
508 kwsysProcessCleanupHandle(&cp->Pipe[i].Reader.Reset);
509 kwsysProcessCleanupHandle(&cp->Pipe[i].Waker.Ready);
510 kwsysProcessCleanupHandle(&cp->Pipe[i].Waker.Go);
511 kwsysProcessCleanupHandle(&cp->Pipe[i].Waker.Reset);
512 }
513

Callers 1

kwsysProcess_NewFunction · 0.70

Calls 6

kwsysProcess_DisownFunction · 0.70
kwsysProcess_WaitForExitFunction · 0.70
kwsysProcess_SetCommandFunction · 0.70
kwsysProcess_SetPipeFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…