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

Function kwsysProcess_Execute

Source/kwsys/ProcessUNIX.c:761–1044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759#undef KWSYSPE_IDX_CHK
760
761void kwsysProcess_Execute(kwsysProcess* cp)
762{
763 int i;
764
765 /* Do not execute a second copy simultaneously. */
766 if (!cp || cp->State == kwsysProcess_State_Executing) {
767 return;
768 }
769
770 /* Make sure we have something to run. */
771 if (cp->NumberOfCommands < 1) {
772 strcpy(cp->ErrorMessage, "No command");
773 cp->State = kwsysProcess_State_Error;
774 return;
775 }
776
777 /* Initialize the control structure for a new process. */
778 if (!kwsysProcessInitialize(cp)) {
779 strcpy(cp->ErrorMessage, "Out of memory");
780 cp->State = kwsysProcess_State_Error;
781 return;
782 }
783
784#if defined(__VMS)
785 /* Make sure pipes behave like streams on VMS. */
786 if (!kwsysProcessSetVMSFeature("DECC$STREAM_PIPE", 1)) {
787 kwsysProcessCleanup(cp, 1);
788 return;
789 }
790#endif
791
792 /* Save the real working directory of this process and change to
793 the working directory for the child processes. This is needed
794 to make pipe file paths evaluate correctly. */
795 if (cp->WorkingDirectory) {
796 int r;
797 if (!getcwd(cp->RealWorkingDirectory,
798 (size_t)(cp->RealWorkingDirectoryLength))) {
799 kwsysProcessCleanup(cp, 1);
800 return;
801 }
802
803 /* Some platforms specify that the chdir call may be
804 interrupted. Repeat the call until it finishes. */
805 while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR)) {
806 }
807 if (r < 0) {
808 kwsysProcessCleanup(cp, 1);
809 return;
810 }
811 }
812
813 /* If not running a detached child, add this object to the global
814 set of process objects that wish to be notified when a child
815 exits. */
816 if (!cp->OptionDetach) {
817 if (!kwsysProcessesAdd(cp)) {
818 kwsysProcessCleanup(cp, 1);

Callers 2

runChild2Function · 0.70
RunProcessMethod · 0.70

Calls 11

pipeFunction · 0.85
kwsysProcessInitializeFunction · 0.70
kwsysProcessCleanupFunction · 0.70
kwsysProcessesAddFunction · 0.70
kwsysProcessCreateFunction · 0.70

Tested by 1

runChild2Function · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…