cmUVProcessChain.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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 UV_VERSION_MAJOR > 1 || \
  284. (UV_VERSION_MAJOR == 1 && UV_VERSION_MINOR >= 48) || \
  285. !defined(CMAKE_USE_SYSTEM_LIBUV)
  286. options.flags |= UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME;
  287. #endif
  288. if (!this->Builder->WorkingDirectory.empty()) {
  289. options.cwd = this->Builder->WorkingDirectory.c_str();
  290. }
  291. std::array<uv_stdio_container_t, 3> stdio;
  292. if (first) {
  293. stdio[0] = this->InputStreamData.Stdio;
  294. } else {
  295. stdio[0] = uv_stdio_container_t();
  296. stdio[0].flags = UV_INHERIT_STREAM;
  297. stdio[0].data.stream = process.InputPipe;
  298. }
  299. if (last) {
  300. stdio[1] = this->OutputStreamData.Stdio;
  301. } else {
  302. stdio[1] = uv_stdio_container_t();
  303. stdio[1].flags = UV_INHERIT_STREAM;
  304. stdio[1].data.stream = process.OutputPipe;
  305. }
  306. stdio[2] = this->ErrorStreamData.Stdio;
  307. options.stdio = stdio.data();
  308. options.stdio_count = 3;
  309. options.exit_cb = [](uv_process_t* handle, int64_t exitStatus,
  310. int termSignal) {
  311. auto* processData = static_cast<ProcessData*>(handle->data);
  312. processData->ProcessStatus.ExitStatus = exitStatus;
  313. processData->ProcessStatus.TermSignal = termSignal;
  314. processData->Finish();
  315. };
  316. if ((process.ProcessStatus.SpawnResult =
  317. process.Process.spawn(*this->Loop, options, &process)) < 0) {
  318. process.Finish();
  319. }
  320. process.InputPipe.reset();
  321. process.OutputPipe.reset();
  322. }
  323. void cmUVProcessChain::InternalData::Finish()
  324. {
  325. this->TempOutputPipe.reset();
  326. this->TempErrorPipe.reset();
  327. this->Valid = true;
  328. }
  329. cmUVProcessChain::cmUVProcessChain()
  330. : Data(cm::make_unique<InternalData>())
  331. {
  332. }
  333. cmUVProcessChain::cmUVProcessChain(cmUVProcessChain&& other) noexcept
  334. : Data(std::move(other.Data))
  335. {
  336. }
  337. cmUVProcessChain::~cmUVProcessChain() = default;
  338. cmUVProcessChain& cmUVProcessChain::operator=(
  339. cmUVProcessChain&& other) noexcept
  340. {
  341. this->Data = std::move(other.Data);
  342. return *this;
  343. }
  344. uv_loop_t& cmUVProcessChain::GetLoop()
  345. {
  346. return *this->Data->Loop;
  347. }
  348. int cmUVProcessChain::OutputStream()
  349. {
  350. return this->Data->OutputStreamData.BuiltinStream;
  351. }
  352. int cmUVProcessChain::ErrorStream()
  353. {
  354. return this->Data->ErrorStreamData.BuiltinStream;
  355. }
  356. bool cmUVProcessChain::Valid() const
  357. {
  358. return this->Data->Valid;
  359. }
  360. bool cmUVProcessChain::Wait(uint64_t milliseconds)
  361. {
  362. bool timeout = false;
  363. cm::uv_timer_ptr timer;
  364. if (milliseconds > 0) {
  365. timer.init(*this->Data->Loop, &timeout);
  366. timer.start(
  367. [](uv_timer_t* handle) {
  368. auto* timeoutPtr = static_cast<bool*>(handle->data);
  369. *timeoutPtr = true;
  370. },
  371. milliseconds, 0);
  372. }
  373. while (!timeout &&
  374. this->Data->ProcessesCompleted < this->Data->Processes.size()) {
  375. uv_run(this->Data->Loop, UV_RUN_ONCE);
  376. }
  377. return !timeout;
  378. }
  379. std::vector<const cmUVProcessChain::Status*> cmUVProcessChain::GetStatus()
  380. const
  381. {
  382. std::vector<const cmUVProcessChain::Status*> statuses(
  383. this->Data->Processes.size(), nullptr);
  384. for (std::size_t i = 0; i < statuses.size(); i++) {
  385. statuses[i] = &this->GetStatus(i);
  386. }
  387. return statuses;
  388. }
  389. const cmUVProcessChain::Status& cmUVProcessChain::GetStatus(
  390. std::size_t index) const
  391. {
  392. return this->Data->Processes[index]->ProcessStatus;
  393. }
  394. bool cmUVProcessChain::Finished() const
  395. {
  396. return this->Data->ProcessesCompleted >= this->Data->Processes.size();
  397. }
  398. std::pair<cmUVProcessChain::ExceptionCode, std::string>
  399. cmUVProcessChain::Status::GetException() const
  400. {
  401. if (this->SpawnResult) {
  402. return std::make_pair(ExceptionCode::Spawn,
  403. uv_strerror(this->SpawnResult));
  404. }
  405. #ifdef _WIN32
  406. if (this->Finished && (this->ExitStatus & 0xF0000000) == 0xC0000000) {
  407. // Child terminated due to exceptional behavior.
  408. switch (this->ExitStatus) {
  409. case STATUS_CONTROL_C_EXIT:
  410. return std::make_pair(ExceptionCode::Interrupt, "User interrupt");
  411. case STATUS_FLOAT_DENORMAL_OPERAND:
  412. return std::make_pair(ExceptionCode::Numerical,
  413. "Floating-point exception (denormal operand)");
  414. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  415. return std::make_pair(ExceptionCode::Numerical, "Divide-by-zero");
  416. case STATUS_FLOAT_INEXACT_RESULT:
  417. return std::make_pair(ExceptionCode::Numerical,
  418. "Floating-point exception (inexact result)");
  419. case STATUS_FLOAT_INVALID_OPERATION:
  420. return std::make_pair(ExceptionCode::Numerical,
  421. "Invalid floating-point operation");
  422. case STATUS_FLOAT_OVERFLOW:
  423. return std::make_pair(ExceptionCode::Numerical,
  424. "Floating-point overflow");
  425. case STATUS_FLOAT_STACK_CHECK:
  426. return std::make_pair(ExceptionCode::Numerical,
  427. "Floating-point stack check failed");
  428. case STATUS_FLOAT_UNDERFLOW:
  429. return std::make_pair(ExceptionCode::Numerical,
  430. "Floating-point underflow");
  431. # ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  432. case STATUS_FLOAT_MULTIPLE_FAULTS:
  433. return std::make_pair(ExceptionCode::Numerical,
  434. "Floating-point exception (multiple faults)");
  435. # endif
  436. # ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  437. case STATUS_FLOAT_MULTIPLE_TRAPS:
  438. return std::make_pair(ExceptionCode::Numerical,
  439. "Floating-point exception (multiple traps)");
  440. # endif
  441. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  442. return std::make_pair(ExceptionCode::Numerical,
  443. "Integer divide-by-zero");
  444. case STATUS_INTEGER_OVERFLOW:
  445. return std::make_pair(ExceptionCode::Numerical, "Integer overflow");
  446. case STATUS_DATATYPE_MISALIGNMENT:
  447. return std::make_pair(ExceptionCode::Fault, "Datatype misalignment");
  448. case STATUS_ACCESS_VIOLATION:
  449. return std::make_pair(ExceptionCode::Fault, "Access violation");
  450. case STATUS_IN_PAGE_ERROR:
  451. return std::make_pair(ExceptionCode::Fault, "In-page error");
  452. case STATUS_INVALID_HANDLE:
  453. return std::make_pair(ExceptionCode::Fault, "Invalid handle");
  454. case STATUS_NONCONTINUABLE_EXCEPTION:
  455. return std::make_pair(ExceptionCode::Fault,
  456. "Noncontinuable exception");
  457. case STATUS_INVALID_DISPOSITION:
  458. return std::make_pair(ExceptionCode::Fault, "Invalid disposition");
  459. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  460. return std::make_pair(ExceptionCode::Fault, "Array bounds exceeded");
  461. case STATUS_STACK_OVERFLOW:
  462. return std::make_pair(ExceptionCode::Fault, "Stack overflow");
  463. case STATUS_ILLEGAL_INSTRUCTION:
  464. return std::make_pair(ExceptionCode::Illegal, "Illegal instruction");
  465. case STATUS_PRIVILEGED_INSTRUCTION:
  466. return std::make_pair(ExceptionCode::Illegal,
  467. "Privileged instruction");
  468. case STATUS_NO_MEMORY:
  469. default: {
  470. char buf[256];
  471. snprintf(buf, sizeof(buf), "Exit code 0x%x\n",
  472. static_cast<unsigned int>(this->ExitStatus));
  473. return std::make_pair(ExceptionCode::Other, buf);
  474. }
  475. }
  476. }
  477. #else
  478. if (this->Finished && this->TermSignal) {
  479. switch (this->TermSignal) {
  480. # ifdef SIGSEGV
  481. case SIGSEGV:
  482. return std::make_pair(ExceptionCode::Fault, "Segmentation fault");
  483. # endif
  484. # ifdef SIGBUS
  485. # if !defined(SIGSEGV) || SIGBUS != SIGSEGV
  486. case SIGBUS:
  487. return std::make_pair(ExceptionCode::Fault, "Bus error");
  488. # endif
  489. # endif
  490. # ifdef SIGFPE
  491. case SIGFPE:
  492. return std::make_pair(ExceptionCode::Numerical,
  493. "Floating-point exception");
  494. # endif
  495. # ifdef SIGILL
  496. case SIGILL:
  497. return std::make_pair(ExceptionCode::Illegal, "Illegal instruction");
  498. # endif
  499. # ifdef SIGINT
  500. case SIGINT:
  501. return std::make_pair(ExceptionCode::Interrupt, "User interrupt");
  502. # endif
  503. # ifdef SIGABRT
  504. case SIGABRT:
  505. return std::make_pair(ExceptionCode::Other, "Subprocess aborted");
  506. # endif
  507. # ifdef SIGKILL
  508. case SIGKILL:
  509. return std::make_pair(ExceptionCode::Other, "Subprocess killed");
  510. # endif
  511. # ifdef SIGTERM
  512. case SIGTERM:
  513. return std::make_pair(ExceptionCode::Other, "Subprocess terminated");
  514. # endif
  515. # ifdef SIGHUP
  516. case SIGHUP:
  517. return std::make_pair(ExceptionCode::Other, "SIGHUP");
  518. # endif
  519. # ifdef SIGQUIT
  520. case SIGQUIT:
  521. return std::make_pair(ExceptionCode::Other, "SIGQUIT");
  522. # endif
  523. # ifdef SIGTRAP
  524. case SIGTRAP:
  525. return std::make_pair(ExceptionCode::Other, "SIGTRAP");
  526. # endif
  527. # ifdef SIGIOT
  528. # if !defined(SIGABRT) || SIGIOT != SIGABRT
  529. case SIGIOT:
  530. return std::make_pair(ExceptionCode::Other, "SIGIOT");
  531. # endif
  532. # endif
  533. # ifdef SIGUSR1
  534. case SIGUSR1:
  535. return std::make_pair(ExceptionCode::Other, "SIGUSR1");
  536. # endif
  537. # ifdef SIGUSR2
  538. case SIGUSR2:
  539. return std::make_pair(ExceptionCode::Other, "SIGUSR2");
  540. # endif
  541. # ifdef SIGPIPE
  542. case SIGPIPE:
  543. return std::make_pair(ExceptionCode::Other, "SIGPIPE");
  544. # endif
  545. # ifdef SIGALRM
  546. case SIGALRM:
  547. return std::make_pair(ExceptionCode::Other, "SIGALRM");
  548. # endif
  549. # ifdef SIGSTKFLT
  550. case SIGSTKFLT:
  551. return std::make_pair(ExceptionCode::Other, "SIGSTKFLT");
  552. # endif
  553. # ifdef SIGCHLD
  554. case SIGCHLD:
  555. return std::make_pair(ExceptionCode::Other, "SIGCHLD");
  556. # elif defined(SIGCLD)
  557. case SIGCLD:
  558. return std::make_pair(ExceptionCode::Other, "SIGCLD");
  559. # endif
  560. # ifdef SIGCONT
  561. case SIGCONT:
  562. return std::make_pair(ExceptionCode::Other, "SIGCONT");
  563. # endif
  564. # ifdef SIGSTOP
  565. case SIGSTOP:
  566. return std::make_pair(ExceptionCode::Other, "SIGSTOP");
  567. # endif
  568. # ifdef SIGTSTP
  569. case SIGTSTP:
  570. return std::make_pair(ExceptionCode::Other, "SIGTSTP");
  571. # endif
  572. # ifdef SIGTTIN
  573. case SIGTTIN:
  574. return std::make_pair(ExceptionCode::Other, "SIGTTIN");
  575. # endif
  576. # ifdef SIGTTOU
  577. case SIGTTOU:
  578. return std::make_pair(ExceptionCode::Other, "SIGTTOU");
  579. # endif
  580. # ifdef SIGURG
  581. case SIGURG:
  582. return std::make_pair(ExceptionCode::Other, "SIGURG");
  583. # endif
  584. # ifdef SIGXCPU
  585. case SIGXCPU:
  586. return std::make_pair(ExceptionCode::Other, "SIGXCPU");
  587. # endif
  588. # ifdef SIGXFSZ
  589. case SIGXFSZ:
  590. return std::make_pair(ExceptionCode::Other, "SIGXFSZ");
  591. # endif
  592. # ifdef SIGVTALRM
  593. case SIGVTALRM:
  594. return std::make_pair(ExceptionCode::Other, "SIGVTALRM");
  595. # endif
  596. # ifdef SIGPROF
  597. case SIGPROF:
  598. return std::make_pair(ExceptionCode::Other, "SIGPROF");
  599. # endif
  600. # ifdef SIGWINCH
  601. case SIGWINCH:
  602. return std::make_pair(ExceptionCode::Other, "SIGWINCH");
  603. # endif
  604. # ifdef SIGPOLL
  605. case SIGPOLL:
  606. return std::make_pair(ExceptionCode::Other, "SIGPOLL");
  607. # endif
  608. # ifdef SIGIO
  609. # if !defined(SIGPOLL) || SIGIO != SIGPOLL
  610. case SIGIO:
  611. return std::make_pair(ExceptionCode::Other, "SIGIO");
  612. # endif
  613. # endif
  614. # ifdef SIGPWR
  615. case SIGPWR:
  616. return std::make_pair(ExceptionCode::Other, "SIGPWR");
  617. # endif
  618. # ifdef SIGSYS
  619. case SIGSYS:
  620. return std::make_pair(ExceptionCode::Other, "SIGSYS");
  621. # endif
  622. # ifdef SIGUNUSED
  623. # if !defined(SIGSYS) || SIGUNUSED != SIGSYS
  624. case SIGUNUSED:
  625. return std::make_pair(ExceptionCode::Other, "SIGUNUSED");
  626. # endif
  627. # endif
  628. default: {
  629. char buf[256];
  630. snprintf(buf, sizeof(buf), "Signal %d", this->TermSignal);
  631. return std::make_pair(ExceptionCode::Other, buf);
  632. }
  633. }
  634. }
  635. #endif
  636. return std::make_pair(ExceptionCode::None, "");
  637. }
  638. void cmUVProcessChain::InternalData::ProcessData::Finish()
  639. {
  640. this->ProcessStatus.Finished = true;
  641. this->Data->ProcessesCompleted++;
  642. }