cmUVProcessChain.cxx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmUVProcessChain.h"
  4. #include <array>
  5. #include <csignal>
  6. #include <cstdio>
  7. #include <istream> // IWYU pragma: keep
  8. #include <utility>
  9. #include <cm/memory>
  10. #include <cm3p/uv.h>
  11. #include "cm_fileno.hxx"
  12. #include "cmGetPipes.h"
  13. #include "cmUVHandlePtr.h"
  14. struct cmUVProcessChain::InternalData
  15. {
  16. struct StreamData
  17. {
  18. int BuiltinStream = -1;
  19. uv_stdio_container_t Stdio;
  20. };
  21. struct ProcessData
  22. {
  23. cmUVProcessChain::InternalData* Data;
  24. cm::uv_process_ptr Process;
  25. cm::uv_pipe_ptr InputPipe;
  26. cm::uv_pipe_ptr OutputPipe;
  27. Status ProcessStatus;
  28. void Finish();
  29. };
  30. const cmUVProcessChainBuilder* Builder = nullptr;
  31. bool Valid = false;
  32. cm::uv_loop_ptr BuiltinLoop;
  33. uv_loop_t* Loop;
  34. StreamData InputStreamData;
  35. StreamData OutputStreamData;
  36. StreamData ErrorStreamData;
  37. cm::uv_pipe_ptr TempOutputPipe;
  38. cm::uv_pipe_ptr TempErrorPipe;
  39. unsigned int ProcessesCompleted = 0;
  40. std::vector<std::unique_ptr<ProcessData>> Processes;
  41. bool Prepare(const cmUVProcessChainBuilder* builder);
  42. void SpawnProcess(
  43. std::size_t index,
  44. const cmUVProcessChainBuilder::ProcessConfiguration& config, bool first,
  45. bool last);
  46. void Finish();
  47. };
  48. cmUVProcessChainBuilder::cmUVProcessChainBuilder() = default;
  49. cmUVProcessChainBuilder& cmUVProcessChainBuilder::AddCommand(
  50. const std::vector<std::string>& arguments)
  51. {
  52. if (!arguments.empty()) {
  53. this->Processes.emplace_back();
  54. this->Processes.back().Arguments = arguments;
  55. }
  56. return *this;
  57. }
  58. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetBuiltinLoop()
  59. {
  60. this->Loop = nullptr;
  61. return *this;
  62. }
  63. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalLoop(
  64. uv_loop_t& loop)
  65. {
  66. this->Loop = &loop;
  67. return *this;
  68. }
  69. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetNoStream(Stream stdio)
  70. {
  71. switch (stdio) {
  72. case Stream_INPUT:
  73. case Stream_OUTPUT:
  74. case Stream_ERROR: {
  75. auto& streamData = this->Stdio[stdio];
  76. streamData.Type = None;
  77. break;
  78. }
  79. }
  80. return *this;
  81. }
  82. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetBuiltinStream(
  83. Stream stdio)
  84. {
  85. switch (stdio) {
  86. case Stream_INPUT:
  87. // FIXME
  88. break;
  89. case Stream_OUTPUT:
  90. case Stream_ERROR: {
  91. auto& streamData = this->Stdio[stdio];
  92. streamData.Type = Builtin;
  93. break;
  94. }
  95. }
  96. return *this;
  97. }
  98. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalStream(
  99. Stream stdio, int fd)
  100. {
  101. switch (stdio) {
  102. case Stream_INPUT:
  103. case Stream_OUTPUT:
  104. case Stream_ERROR: {
  105. auto& streamData = this->Stdio[stdio];
  106. streamData.Type = External;
  107. streamData.FileDescriptor = fd;
  108. break;
  109. }
  110. }
  111. return *this;
  112. }
  113. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalStream(
  114. Stream stdio, FILE* stream)
  115. {
  116. int fd = cm_fileno(stream);
  117. if (fd >= 0) {
  118. return this->SetExternalStream(stdio, fd);
  119. }
  120. return this->SetNoStream(stdio);
  121. }
  122. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetMergedBuiltinStreams()
  123. {
  124. this->MergedBuiltinStreams = true;
  125. return this->SetBuiltinStream(Stream_OUTPUT).SetBuiltinStream(Stream_ERROR);
  126. }
  127. cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetWorkingDirectory(
  128. std::string dir)
  129. {
  130. this->WorkingDirectory = std::move(dir);
  131. return *this;
  132. }
  133. uv_loop_t* cmUVProcessChainBuilder::GetLoop() const
  134. {
  135. return this->Loop;
  136. }
  137. cmUVProcessChain cmUVProcessChainBuilder::Start() const
  138. {
  139. cmUVProcessChain chain;
  140. if (!chain.Data->Prepare(this)) {
  141. return chain;
  142. }
  143. for (std::size_t i = 0; i < this->Processes.size(); i++) {
  144. chain.Data->SpawnProcess(i, this->Processes[i], i == 0,
  145. i == this->Processes.size() - 1);
  146. }
  147. chain.Data->Finish();
  148. return chain;
  149. }
  150. bool cmUVProcessChain::InternalData::Prepare(
  151. const cmUVProcessChainBuilder* builder)
  152. {
  153. this->Builder = builder;
  154. if (this->Builder->Loop) {
  155. this->Loop = this->Builder->Loop;
  156. } else {
  157. this->BuiltinLoop.init();
  158. this->Loop = this->BuiltinLoop;
  159. }
  160. auto const& input =
  161. this->Builder->Stdio[cmUVProcessChainBuilder::Stream_INPUT];
  162. auto& inputData = this->InputStreamData;
  163. switch (input.Type) {
  164. case cmUVProcessChainBuilder::None:
  165. inputData.Stdio.flags = UV_IGNORE;
  166. break;
  167. case cmUVProcessChainBuilder::Builtin: {
  168. // FIXME
  169. break;
  170. }
  171. case cmUVProcessChainBuilder::External:
  172. inputData.Stdio.flags = UV_INHERIT_FD;
  173. inputData.Stdio.data.fd = input.FileDescriptor;
  174. break;
  175. }
  176. auto const& error =
  177. this->Builder->Stdio[cmUVProcessChainBuilder::Stream_ERROR];
  178. auto& errorData = this->ErrorStreamData;
  179. switch (error.Type) {
  180. case cmUVProcessChainBuilder::None:
  181. errorData.Stdio.flags = UV_IGNORE;
  182. break;
  183. case cmUVProcessChainBuilder::Builtin: {
  184. int pipeFd[2];
  185. if (cmGetPipes(pipeFd) < 0) {
  186. return false;
  187. }
  188. errorData.BuiltinStream = pipeFd[0];
  189. errorData.Stdio.flags = UV_INHERIT_FD;
  190. errorData.Stdio.data.fd = pipeFd[1];
  191. if (this->TempErrorPipe.init(*this->Loop, 0) < 0) {
  192. return false;
  193. }
  194. if (uv_pipe_open(this->TempErrorPipe, errorData.Stdio.data.fd) < 0) {
  195. return false;
  196. }
  197. break;
  198. }
  199. case cmUVProcessChainBuilder::External:
  200. errorData.Stdio.flags = UV_INHERIT_FD;
  201. errorData.Stdio.data.fd = error.FileDescriptor;
  202. break;
  203. }
  204. auto const& output =
  205. this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT];
  206. auto& outputData = this->OutputStreamData;
  207. switch (output.Type) {
  208. case cmUVProcessChainBuilder::None:
  209. outputData.Stdio.flags = UV_IGNORE;
  210. break;
  211. case cmUVProcessChainBuilder::Builtin:
  212. if (this->Builder->MergedBuiltinStreams) {
  213. outputData.BuiltinStream = errorData.BuiltinStream;
  214. outputData.Stdio.flags = UV_INHERIT_FD;
  215. outputData.Stdio.data.fd = errorData.Stdio.data.fd;
  216. } else {
  217. int pipeFd[2];
  218. if (cmGetPipes(pipeFd) < 0) {
  219. return false;
  220. }
  221. outputData.BuiltinStream = pipeFd[0];
  222. outputData.Stdio.flags = UV_INHERIT_FD;
  223. outputData.Stdio.data.fd = pipeFd[1];
  224. if (this->TempOutputPipe.init(*this->Loop, 0) < 0) {
  225. return false;
  226. }
  227. if (uv_pipe_open(this->TempOutputPipe, outputData.Stdio.data.fd) < 0) {
  228. return false;
  229. }
  230. }
  231. break;
  232. case cmUVProcessChainBuilder::External:
  233. outputData.Stdio.flags = UV_INHERIT_FD;
  234. outputData.Stdio.data.fd = output.FileDescriptor;
  235. break;
  236. }
  237. bool first = true;
  238. for (std::size_t i = 0; i < this->Builder->Processes.size(); i++) {
  239. this->Processes.emplace_back(cm::make_unique<ProcessData>());
  240. auto& process = *this->Processes.back();
  241. process.Data = this;
  242. process.ProcessStatus.Finished = false;
  243. if (!first) {
  244. auto& prevProcess = *this->Processes[i - 1];
  245. int pipeFd[2];
  246. if (cmGetPipes(pipeFd) < 0) {
  247. return false;
  248. }
  249. if (prevProcess.OutputPipe.init(*this->Loop, 0) < 0) {
  250. return false;
  251. }
  252. if (uv_pipe_open(prevProcess.OutputPipe, pipeFd[1]) < 0) {
  253. return false;
  254. }
  255. if (process.InputPipe.init(*this->Loop, 0) < 0) {
  256. return false;
  257. }
  258. if (uv_pipe_open(process.InputPipe, pipeFd[0]) < 0) {
  259. return false;
  260. }
  261. }
  262. first = false;
  263. }
  264. return true;
  265. }
  266. void cmUVProcessChain::InternalData::SpawnProcess(
  267. std::size_t index,
  268. const cmUVProcessChainBuilder::ProcessConfiguration& config, bool first,
  269. bool last)
  270. {
  271. auto& process = *this->Processes[index];
  272. auto options = uv_process_options_t();
  273. // Bounds were checked at add time, first element is guaranteed to exist
  274. options.file = config.Arguments[0].c_str();
  275. std::vector<const char*> arguments;
  276. arguments.reserve(config.Arguments.size());
  277. for (auto const& arg : config.Arguments) {
  278. arguments.push_back(arg.c_str());
  279. }
  280. arguments.push_back(nullptr);
  281. options.args = const_cast<char**>(arguments.data());
  282. options.flags = UV_PROCESS_WINDOWS_HIDE;
  283. if (!this->Builder->WorkingDirectory.empty()) {
  284. options.cwd = this->Builder->WorkingDirectory.c_str();
  285. }
  286. std::array<uv_stdio_container_t, 3> stdio;
  287. if (first) {
  288. stdio[0] = this->InputStreamData.Stdio;
  289. } else {
  290. stdio[0] = uv_stdio_container_t();
  291. stdio[0].flags = UV_INHERIT_STREAM;
  292. stdio[0].data.stream = process.InputPipe;
  293. }
  294. if (last) {
  295. stdio[1] = this->OutputStreamData.Stdio;
  296. } else {
  297. stdio[1] = uv_stdio_container_t();
  298. stdio[1].flags = UV_INHERIT_STREAM;
  299. stdio[1].data.stream = process.OutputPipe;
  300. }
  301. stdio[2] = this->ErrorStreamData.Stdio;
  302. options.stdio = stdio.data();
  303. options.stdio_count = 3;
  304. options.exit_cb = [](uv_process_t* handle, int64_t exitStatus,
  305. int termSignal) {
  306. auto* processData = static_cast<ProcessData*>(handle->data);
  307. processData->ProcessStatus.ExitStatus = exitStatus;
  308. processData->ProcessStatus.TermSignal = termSignal;
  309. processData->Finish();
  310. };
  311. if ((process.ProcessStatus.SpawnResult =
  312. process.Process.spawn(*this->Loop, options, &process)) < 0) {
  313. process.Finish();
  314. }
  315. process.InputPipe.reset();
  316. process.OutputPipe.reset();
  317. }
  318. void cmUVProcessChain::InternalData::Finish()
  319. {
  320. this->TempOutputPipe.reset();
  321. this->TempErrorPipe.reset();
  322. this->Valid = true;
  323. }
  324. cmUVProcessChain::cmUVProcessChain()
  325. : Data(cm::make_unique<InternalData>())
  326. {
  327. }
  328. cmUVProcessChain::cmUVProcessChain(cmUVProcessChain&& other) noexcept
  329. : Data(std::move(other.Data))
  330. {
  331. }
  332. cmUVProcessChain::~cmUVProcessChain() = default;
  333. cmUVProcessChain& cmUVProcessChain::operator=(
  334. cmUVProcessChain&& other) noexcept
  335. {
  336. this->Data = std::move(other.Data);
  337. return *this;
  338. }
  339. uv_loop_t& cmUVProcessChain::GetLoop()
  340. {
  341. return *this->Data->Loop;
  342. }
  343. int cmUVProcessChain::OutputStream()
  344. {
  345. return this->Data->OutputStreamData.BuiltinStream;
  346. }
  347. int cmUVProcessChain::ErrorStream()
  348. {
  349. return this->Data->ErrorStreamData.BuiltinStream;
  350. }
  351. bool cmUVProcessChain::Valid() const
  352. {
  353. return this->Data->Valid;
  354. }
  355. bool cmUVProcessChain::Wait(uint64_t milliseconds)
  356. {
  357. bool timeout = false;
  358. cm::uv_timer_ptr timer;
  359. if (milliseconds > 0) {
  360. timer.init(*this->Data->Loop, &timeout);
  361. timer.start(
  362. [](uv_timer_t* handle) {
  363. auto* timeoutPtr = static_cast<bool*>(handle->data);
  364. *timeoutPtr = true;
  365. },
  366. milliseconds, 0);
  367. }
  368. while (!timeout &&
  369. this->Data->ProcessesCompleted < this->Data->Processes.size()) {
  370. uv_run(this->Data->Loop, UV_RUN_ONCE);
  371. }
  372. return !timeout;
  373. }
  374. std::vector<const cmUVProcessChain::Status*> cmUVProcessChain::GetStatus()
  375. const
  376. {
  377. std::vector<const cmUVProcessChain::Status*> statuses(
  378. this->Data->Processes.size(), nullptr);
  379. for (std::size_t i = 0; i < statuses.size(); i++) {
  380. statuses[i] = &this->GetStatus(i);
  381. }
  382. return statuses;
  383. }
  384. const cmUVProcessChain::Status& cmUVProcessChain::GetStatus(
  385. std::size_t index) const
  386. {
  387. return this->Data->Processes[index]->ProcessStatus;
  388. }
  389. bool cmUVProcessChain::Finished() const
  390. {
  391. return this->Data->ProcessesCompleted >= this->Data->Processes.size();
  392. }
  393. std::pair<cmUVProcessChain::ExceptionCode, std::string>
  394. cmUVProcessChain::Status::GetException() const
  395. {
  396. if (this->SpawnResult) {
  397. return std::make_pair(ExceptionCode::Spawn,
  398. uv_strerror(this->SpawnResult));
  399. }
  400. #ifdef _WIN32
  401. if (this->Finished && (this->ExitStatus & 0xF0000000) == 0xC0000000) {
  402. // Child terminated due to exceptional behavior.
  403. switch (this->ExitStatus) {
  404. case STATUS_CONTROL_C_EXIT:
  405. return std::make_pair(ExceptionCode::Interrupt, "User interrupt");
  406. case STATUS_FLOAT_DENORMAL_OPERAND:
  407. return std::make_pair(ExceptionCode::Numerical,
  408. "Floating-point exception (denormal operand)");
  409. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  410. return std::make_pair(ExceptionCode::Numerical, "Divide-by-zero");
  411. case STATUS_FLOAT_INEXACT_RESULT:
  412. return std::make_pair(ExceptionCode::Numerical,
  413. "Floating-point exception (inexact result)");
  414. case STATUS_FLOAT_INVALID_OPERATION:
  415. return std::make_pair(ExceptionCode::Numerical,
  416. "Invalid floating-point operation");
  417. case STATUS_FLOAT_OVERFLOW:
  418. return std::make_pair(ExceptionCode::Numerical,
  419. "Floating-point overflow");
  420. case STATUS_FLOAT_STACK_CHECK:
  421. return std::make_pair(ExceptionCode::Numerical,
  422. "Floating-point stack check failed");
  423. case STATUS_FLOAT_UNDERFLOW:
  424. return std::make_pair(ExceptionCode::Numerical,
  425. "Floating-point underflow");
  426. # ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  427. case STATUS_FLOAT_MULTIPLE_FAULTS:
  428. return std::make_pair(ExceptionCode::Numerical,
  429. "Floating-point exception (multiple faults)");
  430. # endif
  431. # ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  432. case STATUS_FLOAT_MULTIPLE_TRAPS:
  433. return std::make_pair(ExceptionCode::Numerical,
  434. "Floating-point exception (multiple traps)");
  435. # endif
  436. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  437. return std::make_pair(ExceptionCode::Numerical,
  438. "Integer divide-by-zero");
  439. case STATUS_INTEGER_OVERFLOW:
  440. return std::make_pair(ExceptionCode::Numerical, "Integer overflow");
  441. case STATUS_DATATYPE_MISALIGNMENT:
  442. return std::make_pair(ExceptionCode::Fault, "Datatype misalignment");
  443. case STATUS_ACCESS_VIOLATION:
  444. return std::make_pair(ExceptionCode::Fault, "Access violation");
  445. case STATUS_IN_PAGE_ERROR:
  446. return std::make_pair(ExceptionCode::Fault, "In-page error");
  447. case STATUS_INVALID_HANDLE:
  448. return std::make_pair(ExceptionCode::Fault, "Invalid handle");
  449. case STATUS_NONCONTINUABLE_EXCEPTION:
  450. return std::make_pair(ExceptionCode::Fault,
  451. "Noncontinuable exception");
  452. case STATUS_INVALID_DISPOSITION:
  453. return std::make_pair(ExceptionCode::Fault, "Invalid disposition");
  454. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  455. return std::make_pair(ExceptionCode::Fault, "Array bounds exceeded");
  456. case STATUS_STACK_OVERFLOW:
  457. return std::make_pair(ExceptionCode::Fault, "Stack overflow");
  458. case STATUS_ILLEGAL_INSTRUCTION:
  459. return std::make_pair(ExceptionCode::Illegal, "Illegal instruction");
  460. case STATUS_PRIVILEGED_INSTRUCTION:
  461. return std::make_pair(ExceptionCode::Illegal,
  462. "Privileged instruction");
  463. case STATUS_NO_MEMORY:
  464. default: {
  465. char buf[256];
  466. snprintf(buf, sizeof(buf), "Exit code 0x%x\n",
  467. static_cast<unsigned int>(this->ExitStatus));
  468. return std::make_pair(ExceptionCode::Other, buf);
  469. }
  470. }
  471. }
  472. #else
  473. if (this->Finished && this->TermSignal) {
  474. switch (this->TermSignal) {
  475. # ifdef SIGSEGV
  476. case SIGSEGV:
  477. return std::make_pair(ExceptionCode::Fault, "Segmentation fault");
  478. # endif
  479. # ifdef SIGBUS
  480. # if !defined(SIGSEGV) || SIGBUS != SIGSEGV
  481. case SIGBUS:
  482. return std::make_pair(ExceptionCode::Fault, "Bus error");
  483. # endif
  484. # endif
  485. # ifdef SIGFPE
  486. case SIGFPE:
  487. return std::make_pair(ExceptionCode::Numerical,
  488. "Floating-point exception");
  489. # endif
  490. # ifdef SIGILL
  491. case SIGILL:
  492. return std::make_pair(ExceptionCode::Illegal, "Illegal instruction");
  493. # endif
  494. # ifdef SIGINT
  495. case SIGINT:
  496. return std::make_pair(ExceptionCode::Interrupt, "User interrupt");
  497. # endif
  498. # ifdef SIGABRT
  499. case SIGABRT:
  500. return std::make_pair(ExceptionCode::Other, "Subprocess aborted");
  501. # endif
  502. # ifdef SIGKILL
  503. case SIGKILL:
  504. return std::make_pair(ExceptionCode::Other, "Subprocess killed");
  505. # endif
  506. # ifdef SIGTERM
  507. case SIGTERM:
  508. return std::make_pair(ExceptionCode::Other, "Subprocess terminated");
  509. # endif
  510. # ifdef SIGHUP
  511. case SIGHUP:
  512. return std::make_pair(ExceptionCode::Other, "SIGHUP");
  513. # endif
  514. # ifdef SIGQUIT
  515. case SIGQUIT:
  516. return std::make_pair(ExceptionCode::Other, "SIGQUIT");
  517. # endif
  518. # ifdef SIGTRAP
  519. case SIGTRAP:
  520. return std::make_pair(ExceptionCode::Other, "SIGTRAP");
  521. # endif
  522. # ifdef SIGIOT
  523. # if !defined(SIGABRT) || SIGIOT != SIGABRT
  524. case SIGIOT:
  525. return std::make_pair(ExceptionCode::Other, "SIGIOT");
  526. # endif
  527. # endif
  528. # ifdef SIGUSR1
  529. case SIGUSR1:
  530. return std::make_pair(ExceptionCode::Other, "SIGUSR1");
  531. # endif
  532. # ifdef SIGUSR2
  533. case SIGUSR2:
  534. return std::make_pair(ExceptionCode::Other, "SIGUSR2");
  535. # endif
  536. # ifdef SIGPIPE
  537. case SIGPIPE:
  538. return std::make_pair(ExceptionCode::Other, "SIGPIPE");
  539. # endif
  540. # ifdef SIGALRM
  541. case SIGALRM:
  542. return std::make_pair(ExceptionCode::Other, "SIGALRM");
  543. # endif
  544. # ifdef SIGSTKFLT
  545. case SIGSTKFLT:
  546. return std::make_pair(ExceptionCode::Other, "SIGSTKFLT");
  547. # endif
  548. # ifdef SIGCHLD
  549. case SIGCHLD:
  550. return std::make_pair(ExceptionCode::Other, "SIGCHLD");
  551. # elif defined(SIGCLD)
  552. case SIGCLD:
  553. return std::make_pair(ExceptionCode::Other, "SIGCLD");
  554. # endif
  555. # ifdef SIGCONT
  556. case SIGCONT:
  557. return std::make_pair(ExceptionCode::Other, "SIGCONT");
  558. # endif
  559. # ifdef SIGSTOP
  560. case SIGSTOP:
  561. return std::make_pair(ExceptionCode::Other, "SIGSTOP");
  562. # endif
  563. # ifdef SIGTSTP
  564. case SIGTSTP:
  565. return std::make_pair(ExceptionCode::Other, "SIGTSTP");
  566. # endif
  567. # ifdef SIGTTIN
  568. case SIGTTIN:
  569. return std::make_pair(ExceptionCode::Other, "SIGTTIN");
  570. # endif
  571. # ifdef SIGTTOU
  572. case SIGTTOU:
  573. return std::make_pair(ExceptionCode::Other, "SIGTTOU");
  574. # endif
  575. # ifdef SIGURG
  576. case SIGURG:
  577. return std::make_pair(ExceptionCode::Other, "SIGURG");
  578. # endif
  579. # ifdef SIGXCPU
  580. case SIGXCPU:
  581. return std::make_pair(ExceptionCode::Other, "SIGXCPU");
  582. # endif
  583. # ifdef SIGXFSZ
  584. case SIGXFSZ:
  585. return std::make_pair(ExceptionCode::Other, "SIGXFSZ");
  586. # endif
  587. # ifdef SIGVTALRM
  588. case SIGVTALRM:
  589. return std::make_pair(ExceptionCode::Other, "SIGVTALRM");
  590. # endif
  591. # ifdef SIGPROF
  592. case SIGPROF:
  593. return std::make_pair(ExceptionCode::Other, "SIGPROF");
  594. # endif
  595. # ifdef SIGWINCH
  596. case SIGWINCH:
  597. return std::make_pair(ExceptionCode::Other, "SIGWINCH");
  598. # endif
  599. # ifdef SIGPOLL
  600. case SIGPOLL:
  601. return std::make_pair(ExceptionCode::Other, "SIGPOLL");
  602. # endif
  603. # ifdef SIGIO
  604. # if !defined(SIGPOLL) || SIGIO != SIGPOLL
  605. case SIGIO:
  606. return std::make_pair(ExceptionCode::Other, "SIGIO");
  607. # endif
  608. # endif
  609. # ifdef SIGPWR
  610. case SIGPWR:
  611. return std::make_pair(ExceptionCode::Other, "SIGPWR");
  612. # endif
  613. # ifdef SIGSYS
  614. case SIGSYS:
  615. return std::make_pair(ExceptionCode::Other, "SIGSYS");
  616. # endif
  617. # ifdef SIGUNUSED
  618. # if !defined(SIGSYS) || SIGUNUSED != SIGSYS
  619. case SIGUNUSED:
  620. return std::make_pair(ExceptionCode::Other, "SIGUNUSED");
  621. # endif
  622. # endif
  623. default: {
  624. char buf[256];
  625. snprintf(buf, sizeof(buf), "Signal %d", this->TermSignal);
  626. return std::make_pair(ExceptionCode::Other, buf);
  627. }
  628. }
  629. }
  630. #endif
  631. return std::make_pair(ExceptionCode::None, "");
  632. }
  633. void cmUVProcessChain::InternalData::ProcessData::Finish()
  634. {
  635. this->ProcessStatus.Finished = true;
  636. this->Data->ProcessesCompleted++;
  637. }