cmProcess.cxx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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 "cmProcess.h"
  4. #include "cmCTest.h"
  5. #include "cmCTestRunTest.h"
  6. #include "cmCTestTestHandler.h"
  7. #include "cmsys/Process.h"
  8. #include <fcntl.h>
  9. #include <iostream>
  10. #include <signal.h>
  11. #include <string>
  12. #if !defined(_WIN32)
  13. # include <unistd.h>
  14. #endif
  15. #include <utility>
  16. #define CM_PROCESS_BUF_SIZE 65536
  17. #if defined(_WIN32) && !defined(__CYGWIN__)
  18. # include <io.h>
  19. static int cmProcessGetPipes(int* fds)
  20. {
  21. SECURITY_ATTRIBUTES attr;
  22. HANDLE readh, writeh;
  23. attr.nLength = sizeof(attr);
  24. attr.lpSecurityDescriptor = nullptr;
  25. attr.bInheritHandle = FALSE;
  26. if (!CreatePipe(&readh, &writeh, &attr, 0))
  27. return uv_translate_sys_error(GetLastError());
  28. fds[0] = _open_osfhandle((intptr_t)readh, 0);
  29. fds[1] = _open_osfhandle((intptr_t)writeh, 0);
  30. if (fds[0] == -1 || fds[1] == -1) {
  31. CloseHandle(readh);
  32. CloseHandle(writeh);
  33. return uv_translate_sys_error(GetLastError());
  34. }
  35. return 0;
  36. }
  37. #else
  38. # include <errno.h>
  39. static int cmProcessGetPipes(int* fds)
  40. {
  41. if (pipe(fds) == -1) {
  42. return uv_translate_sys_error(errno);
  43. }
  44. if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
  45. fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
  46. close(fds[0]);
  47. close(fds[1]);
  48. return uv_translate_sys_error(errno);
  49. }
  50. return 0;
  51. }
  52. #endif
  53. cmProcess::cmProcess(cmCTestRunTest& runner)
  54. : Runner(runner)
  55. , Conv(cmProcessOutput::UTF8, CM_PROCESS_BUF_SIZE)
  56. {
  57. this->Timeout = cmDuration::zero();
  58. this->TotalTime = cmDuration::zero();
  59. this->ExitValue = 0;
  60. this->Id = 0;
  61. this->StartTime = std::chrono::steady_clock::time_point();
  62. }
  63. cmProcess::~cmProcess() = default;
  64. void cmProcess::SetCommand(const char* command)
  65. {
  66. this->Command = command;
  67. }
  68. void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
  69. {
  70. this->Arguments = args;
  71. }
  72. bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
  73. {
  74. this->ProcessState = cmProcess::State::Error;
  75. if (this->Command.empty()) {
  76. return false;
  77. }
  78. this->StartTime = std::chrono::steady_clock::now();
  79. this->ProcessArgs.clear();
  80. // put the command as arg0
  81. this->ProcessArgs.push_back(this->Command.c_str());
  82. // now put the command arguments in
  83. for (std::string const& arg : this->Arguments) {
  84. this->ProcessArgs.push_back(arg.c_str());
  85. }
  86. this->ProcessArgs.push_back(nullptr); // null terminate the list
  87. cm::uv_timer_ptr timer;
  88. int status = timer.init(loop, this);
  89. if (status != 0) {
  90. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  91. "Error initializing timer: " << uv_strerror(status)
  92. << std::endl);
  93. return false;
  94. }
  95. cm::uv_pipe_ptr pipe_writer;
  96. cm::uv_pipe_ptr pipe_reader;
  97. pipe_writer.init(loop, 0);
  98. pipe_reader.init(loop, 0, this);
  99. int fds[2] = { -1, -1 };
  100. status = cmProcessGetPipes(fds);
  101. if (status != 0) {
  102. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  103. "Error initializing pipe: " << uv_strerror(status)
  104. << std::endl);
  105. return false;
  106. }
  107. uv_pipe_open(pipe_reader, fds[0]);
  108. uv_pipe_open(pipe_writer, fds[1]);
  109. uv_stdio_container_t stdio[3];
  110. stdio[0].flags = UV_INHERIT_FD;
  111. stdio[0].data.fd = 0;
  112. stdio[1].flags = UV_INHERIT_STREAM;
  113. stdio[1].data.stream = pipe_writer;
  114. stdio[2] = stdio[1];
  115. uv_process_options_t options = uv_process_options_t();
  116. options.file = this->Command.data();
  117. options.args = const_cast<char**>(this->ProcessArgs.data());
  118. options.stdio_count = 3; // in, out and err
  119. options.exit_cb = &cmProcess::OnExitCB;
  120. options.stdio = stdio;
  121. #if !defined(CMAKE_USE_SYSTEM_LIBUV)
  122. std::vector<char> cpumask;
  123. if (affinity && !affinity->empty()) {
  124. cpumask.resize(static_cast<size_t>(uv_cpumask_size()), 0);
  125. for (auto p : *affinity) {
  126. cpumask[p] = 1;
  127. }
  128. options.cpumask = cpumask.data();
  129. options.cpumask_size = cpumask.size();
  130. } else {
  131. options.cpumask = nullptr;
  132. options.cpumask_size = 0;
  133. }
  134. #else
  135. static_cast<void>(affinity);
  136. #endif
  137. status =
  138. uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);
  139. if (status != 0) {
  140. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  141. "Error starting read events: " << uv_strerror(status)
  142. << std::endl);
  143. return false;
  144. }
  145. status = this->Process.spawn(loop, options, this);
  146. if (status != 0) {
  147. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  148. "Process not started\n " << this->Command << "\n["
  149. << uv_strerror(status) << "]\n");
  150. return false;
  151. }
  152. this->PipeReader = std::move(pipe_reader);
  153. this->Timer = std::move(timer);
  154. this->StartTimer();
  155. this->ProcessState = cmProcess::State::Executing;
  156. return true;
  157. }
  158. void cmProcess::StartTimer()
  159. {
  160. auto properties = this->Runner.GetTestProperties();
  161. auto msec =
  162. std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
  163. if (msec != std::chrono::milliseconds(0) || !properties->ExplicitTimeout) {
  164. this->Timer.start(&cmProcess::OnTimeoutCB,
  165. static_cast<uint64_t>(msec.count()), 0);
  166. }
  167. }
  168. bool cmProcess::Buffer::GetLine(std::string& line)
  169. {
  170. // Scan for the next newline.
  171. for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
  172. if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
  173. // Extract the range first..last as a line.
  174. const char* text = &*this->begin() + this->First;
  175. size_type length = this->Last - this->First;
  176. while (length && text[length - 1] == '\r') {
  177. length--;
  178. }
  179. line.assign(text, length);
  180. // Start a new range for the next line.
  181. ++this->Last;
  182. this->First = Last;
  183. // Return the line extracted.
  184. return true;
  185. }
  186. }
  187. // Available data have been exhausted without a newline.
  188. if (this->First != 0) {
  189. // Move the partial line to the beginning of the buffer.
  190. this->erase(this->begin(), this->begin() + this->First);
  191. this->First = 0;
  192. this->Last = this->size();
  193. }
  194. return false;
  195. }
  196. bool cmProcess::Buffer::GetLast(std::string& line)
  197. {
  198. // Return the partial last line, if any.
  199. if (!this->empty()) {
  200. line.assign(&*this->begin(), this->size());
  201. this->First = this->Last = 0;
  202. this->clear();
  203. return true;
  204. }
  205. return false;
  206. }
  207. void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
  208. const uv_buf_t* buf)
  209. {
  210. auto self = static_cast<cmProcess*>(stream->data);
  211. self->OnRead(nread, buf);
  212. }
  213. void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
  214. {
  215. std::string line;
  216. if (nread > 0) {
  217. std::string strdata;
  218. this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata);
  219. this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
  220. while (this->Output.GetLine(line)) {
  221. this->Runner.CheckOutput(line);
  222. line.clear();
  223. }
  224. return;
  225. }
  226. if (nread == 0) {
  227. return;
  228. }
  229. // The process will provide no more data.
  230. if (nread != UV_EOF) {
  231. auto error = static_cast<int>(nread);
  232. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  233. "Error reading stream: " << uv_strerror(error) << std::endl);
  234. }
  235. // Look for partial last lines.
  236. if (this->Output.GetLast(line)) {
  237. this->Runner.CheckOutput(line);
  238. }
  239. this->ReadHandleClosed = true;
  240. this->PipeReader.reset();
  241. if (this->ProcessHandleClosed) {
  242. uv_timer_stop(this->Timer);
  243. this->Runner.FinalizeTest();
  244. }
  245. }
  246. void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
  247. uv_buf_t* buf)
  248. {
  249. auto self = static_cast<cmProcess*>(handle->data);
  250. self->OnAllocate(suggested_size, buf);
  251. }
  252. void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf)
  253. {
  254. if (this->Buf.size() != CM_PROCESS_BUF_SIZE) {
  255. this->Buf.resize(CM_PROCESS_BUF_SIZE);
  256. }
  257. *buf =
  258. uv_buf_init(this->Buf.data(), static_cast<unsigned int>(this->Buf.size()));
  259. }
  260. void cmProcess::OnTimeoutCB(uv_timer_t* timer)
  261. {
  262. auto self = static_cast<cmProcess*>(timer->data);
  263. self->OnTimeout();
  264. }
  265. void cmProcess::OnTimeout()
  266. {
  267. if (this->ProcessState != cmProcess::State::Executing) {
  268. return;
  269. }
  270. this->ProcessState = cmProcess::State::Expired;
  271. bool const was_still_reading = !this->ReadHandleClosed;
  272. if (!this->ReadHandleClosed) {
  273. this->ReadHandleClosed = true;
  274. this->PipeReader.reset();
  275. }
  276. if (!this->ProcessHandleClosed) {
  277. // Kill the child and let our on-exit handler finish the test.
  278. cmsysProcess_KillPID(static_cast<unsigned long>(this->Process->pid));
  279. } else if (was_still_reading) {
  280. // Our on-exit handler already ran but did not finish the test
  281. // because we were still reading output. We've just dropped
  282. // our read handler, so we need to finish the test now.
  283. this->Runner.FinalizeTest();
  284. }
  285. }
  286. void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
  287. int term_signal)
  288. {
  289. auto self = static_cast<cmProcess*>(process->data);
  290. self->OnExit(exit_status, term_signal);
  291. }
  292. void cmProcess::OnExit(int64_t exit_status, int term_signal)
  293. {
  294. if (this->ProcessState != cmProcess::State::Expired) {
  295. if (
  296. #if defined(_WIN32)
  297. ((DWORD)exit_status & 0xF0000000) == 0xC0000000
  298. #else
  299. term_signal != 0
  300. #endif
  301. ) {
  302. this->ProcessState = cmProcess::State::Exception;
  303. } else {
  304. this->ProcessState = cmProcess::State::Exited;
  305. }
  306. }
  307. // Record exit information.
  308. this->ExitValue = static_cast<int>(exit_status);
  309. this->Signal = term_signal;
  310. this->TotalTime = std::chrono::steady_clock::now() - this->StartTime;
  311. // Because of a processor clock scew the runtime may become slightly
  312. // negative. If someone changed the system clock while the process was
  313. // running this may be even more. Make sure not to report a negative
  314. // duration here.
  315. if (this->TotalTime <= cmDuration::zero()) {
  316. this->TotalTime = cmDuration::zero();
  317. }
  318. this->ProcessHandleClosed = true;
  319. if (this->ReadHandleClosed) {
  320. uv_timer_stop(this->Timer);
  321. this->Runner.FinalizeTest();
  322. }
  323. }
  324. cmProcess::State cmProcess::GetProcessStatus()
  325. {
  326. return this->ProcessState;
  327. }
  328. void cmProcess::ChangeTimeout(cmDuration t)
  329. {
  330. this->Timeout = t;
  331. this->StartTimer();
  332. }
  333. void cmProcess::ResetStartTime()
  334. {
  335. this->StartTime = std::chrono::steady_clock::now();
  336. }
  337. cmProcess::Exception cmProcess::GetExitException()
  338. {
  339. auto exception = Exception::None;
  340. #if defined(_WIN32) && !defined(__CYGWIN__)
  341. auto exit_code = (DWORD)this->ExitValue;
  342. if ((exit_code & 0xF0000000) != 0xC0000000) {
  343. return exception;
  344. }
  345. if (exit_code) {
  346. switch (exit_code) {
  347. case STATUS_DATATYPE_MISALIGNMENT:
  348. case STATUS_ACCESS_VIOLATION:
  349. case STATUS_IN_PAGE_ERROR:
  350. case STATUS_INVALID_HANDLE:
  351. case STATUS_NONCONTINUABLE_EXCEPTION:
  352. case STATUS_INVALID_DISPOSITION:
  353. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  354. case STATUS_STACK_OVERFLOW:
  355. exception = Exception::Fault;
  356. break;
  357. case STATUS_FLOAT_DENORMAL_OPERAND:
  358. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  359. case STATUS_FLOAT_INEXACT_RESULT:
  360. case STATUS_FLOAT_INVALID_OPERATION:
  361. case STATUS_FLOAT_OVERFLOW:
  362. case STATUS_FLOAT_STACK_CHECK:
  363. case STATUS_FLOAT_UNDERFLOW:
  364. # ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  365. case STATUS_FLOAT_MULTIPLE_FAULTS:
  366. # endif
  367. # ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  368. case STATUS_FLOAT_MULTIPLE_TRAPS:
  369. # endif
  370. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  371. case STATUS_INTEGER_OVERFLOW:
  372. exception = Exception::Numerical;
  373. break;
  374. case STATUS_CONTROL_C_EXIT:
  375. exception = Exception::Interrupt;
  376. break;
  377. case STATUS_ILLEGAL_INSTRUCTION:
  378. case STATUS_PRIVILEGED_INSTRUCTION:
  379. exception = Exception::Illegal;
  380. break;
  381. default:
  382. exception = Exception::Other;
  383. }
  384. }
  385. #else
  386. if (this->Signal) {
  387. switch (this->Signal) {
  388. case SIGSEGV:
  389. exception = Exception::Fault;
  390. break;
  391. case SIGFPE:
  392. exception = Exception::Numerical;
  393. break;
  394. case SIGINT:
  395. exception = Exception::Interrupt;
  396. break;
  397. case SIGILL:
  398. exception = Exception::Illegal;
  399. break;
  400. default:
  401. exception = Exception::Other;
  402. }
  403. }
  404. #endif
  405. return exception;
  406. }
  407. std::string cmProcess::GetExitExceptionString()
  408. {
  409. std::string exception_str;
  410. #if defined(_WIN32)
  411. switch (this->ExitValue) {
  412. case STATUS_CONTROL_C_EXIT:
  413. exception_str = "User interrupt";
  414. break;
  415. case STATUS_FLOAT_DENORMAL_OPERAND:
  416. exception_str = "Floating-point exception (denormal operand)";
  417. break;
  418. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  419. exception_str = "Divide-by-zero";
  420. break;
  421. case STATUS_FLOAT_INEXACT_RESULT:
  422. exception_str = "Floating-point exception (inexact result)";
  423. break;
  424. case STATUS_FLOAT_INVALID_OPERATION:
  425. exception_str = "Invalid floating-point operation";
  426. break;
  427. case STATUS_FLOAT_OVERFLOW:
  428. exception_str = "Floating-point overflow";
  429. break;
  430. case STATUS_FLOAT_STACK_CHECK:
  431. exception_str = "Floating-point stack check failed";
  432. break;
  433. case STATUS_FLOAT_UNDERFLOW:
  434. exception_str = "Floating-point underflow";
  435. break;
  436. # ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  437. case STATUS_FLOAT_MULTIPLE_FAULTS:
  438. exception_str = "Floating-point exception (multiple faults)";
  439. break;
  440. # endif
  441. # ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  442. case STATUS_FLOAT_MULTIPLE_TRAPS:
  443. exception_str = "Floating-point exception (multiple traps)";
  444. break;
  445. # endif
  446. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  447. exception_str = "Integer divide-by-zero";
  448. break;
  449. case STATUS_INTEGER_OVERFLOW:
  450. exception_str = "Integer overflow";
  451. break;
  452. case STATUS_DATATYPE_MISALIGNMENT:
  453. exception_str = "Datatype misalignment";
  454. break;
  455. case STATUS_ACCESS_VIOLATION:
  456. exception_str = "Access violation";
  457. break;
  458. case STATUS_IN_PAGE_ERROR:
  459. exception_str = "In-page error";
  460. break;
  461. case STATUS_INVALID_HANDLE:
  462. exception_str = "Invalid handle";
  463. break;
  464. case STATUS_NONCONTINUABLE_EXCEPTION:
  465. exception_str = "Noncontinuable exception";
  466. break;
  467. case STATUS_INVALID_DISPOSITION:
  468. exception_str = "Invalid disposition";
  469. break;
  470. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  471. exception_str = "Array bounds exceeded";
  472. break;
  473. case STATUS_STACK_OVERFLOW:
  474. exception_str = "Stack overflow";
  475. break;
  476. case STATUS_ILLEGAL_INSTRUCTION:
  477. exception_str = "Illegal instruction";
  478. break;
  479. case STATUS_PRIVILEGED_INSTRUCTION:
  480. exception_str = "Privileged instruction";
  481. break;
  482. case STATUS_NO_MEMORY:
  483. default:
  484. char buf[1024];
  485. _snprintf(buf, 1024, "Exit code 0x%x\n", this->ExitValue);
  486. exception_str.assign(buf);
  487. }
  488. #else
  489. switch (this->Signal) {
  490. # ifdef SIGSEGV
  491. case SIGSEGV:
  492. exception_str = "Segmentation fault";
  493. break;
  494. # endif
  495. # ifdef SIGBUS
  496. # if !defined(SIGSEGV) || SIGBUS != SIGSEGV
  497. case SIGBUS:
  498. exception_str = "Bus error";
  499. break;
  500. # endif
  501. # endif
  502. # ifdef SIGFPE
  503. case SIGFPE:
  504. exception_str = "Floating-point exception";
  505. break;
  506. # endif
  507. # ifdef SIGILL
  508. case SIGILL:
  509. exception_str = "Illegal instruction";
  510. break;
  511. # endif
  512. # ifdef SIGINT
  513. case SIGINT:
  514. exception_str = "User interrupt";
  515. break;
  516. # endif
  517. # ifdef SIGABRT
  518. case SIGABRT:
  519. exception_str = "Child aborted";
  520. break;
  521. # endif
  522. # ifdef SIGKILL
  523. case SIGKILL:
  524. exception_str = "Child killed";
  525. break;
  526. # endif
  527. # ifdef SIGTERM
  528. case SIGTERM:
  529. exception_str = "Child terminated";
  530. break;
  531. # endif
  532. # ifdef SIGHUP
  533. case SIGHUP:
  534. exception_str = "SIGHUP";
  535. break;
  536. # endif
  537. # ifdef SIGQUIT
  538. case SIGQUIT:
  539. exception_str = "SIGQUIT";
  540. break;
  541. # endif
  542. # ifdef SIGTRAP
  543. case SIGTRAP:
  544. exception_str = "SIGTRAP";
  545. break;
  546. # endif
  547. # ifdef SIGIOT
  548. # if !defined(SIGABRT) || SIGIOT != SIGABRT
  549. case SIGIOT:
  550. exception_str = "SIGIOT";
  551. break;
  552. # endif
  553. # endif
  554. # ifdef SIGUSR1
  555. case SIGUSR1:
  556. exception_str = "SIGUSR1";
  557. break;
  558. # endif
  559. # ifdef SIGUSR2
  560. case SIGUSR2:
  561. exception_str = "SIGUSR2";
  562. break;
  563. # endif
  564. # ifdef SIGPIPE
  565. case SIGPIPE:
  566. exception_str = "SIGPIPE";
  567. break;
  568. # endif
  569. # ifdef SIGALRM
  570. case SIGALRM:
  571. exception_str = "SIGALRM";
  572. break;
  573. # endif
  574. # ifdef SIGSTKFLT
  575. case SIGSTKFLT:
  576. exception_str = "SIGSTKFLT";
  577. break;
  578. # endif
  579. # ifdef SIGCHLD
  580. case SIGCHLD:
  581. exception_str = "SIGCHLD";
  582. break;
  583. # elif defined(SIGCLD)
  584. case SIGCLD:
  585. exception_str = "SIGCLD";
  586. break;
  587. # endif
  588. # ifdef SIGCONT
  589. case SIGCONT:
  590. exception_str = "SIGCONT";
  591. break;
  592. # endif
  593. # ifdef SIGSTOP
  594. case SIGSTOP:
  595. exception_str = "SIGSTOP";
  596. break;
  597. # endif
  598. # ifdef SIGTSTP
  599. case SIGTSTP:
  600. exception_str = "SIGTSTP";
  601. break;
  602. # endif
  603. # ifdef SIGTTIN
  604. case SIGTTIN:
  605. exception_str = "SIGTTIN";
  606. break;
  607. # endif
  608. # ifdef SIGTTOU
  609. case SIGTTOU:
  610. exception_str = "SIGTTOU";
  611. break;
  612. # endif
  613. # ifdef SIGURG
  614. case SIGURG:
  615. exception_str = "SIGURG";
  616. break;
  617. # endif
  618. # ifdef SIGXCPU
  619. case SIGXCPU:
  620. exception_str = "SIGXCPU";
  621. break;
  622. # endif
  623. # ifdef SIGXFSZ
  624. case SIGXFSZ:
  625. exception_str = "SIGXFSZ";
  626. break;
  627. # endif
  628. # ifdef SIGVTALRM
  629. case SIGVTALRM:
  630. exception_str = "SIGVTALRM";
  631. break;
  632. # endif
  633. # ifdef SIGPROF
  634. case SIGPROF:
  635. exception_str = "SIGPROF";
  636. break;
  637. # endif
  638. # ifdef SIGWINCH
  639. case SIGWINCH:
  640. exception_str = "SIGWINCH";
  641. break;
  642. # endif
  643. # ifdef SIGPOLL
  644. case SIGPOLL:
  645. exception_str = "SIGPOLL";
  646. break;
  647. # endif
  648. # ifdef SIGIO
  649. # if !defined(SIGPOLL) || SIGIO != SIGPOLL
  650. case SIGIO:
  651. exception_str = "SIGIO";
  652. break;
  653. # endif
  654. # endif
  655. # ifdef SIGPWR
  656. case SIGPWR:
  657. exception_str = "SIGPWR";
  658. break;
  659. # endif
  660. # ifdef SIGSYS
  661. case SIGSYS:
  662. exception_str = "SIGSYS";
  663. break;
  664. # endif
  665. # ifdef SIGUNUSED
  666. # if !defined(SIGSYS) || SIGUNUSED != SIGSYS
  667. case SIGUNUSED:
  668. exception_str = "SIGUNUSED";
  669. break;
  670. # endif
  671. # endif
  672. default:
  673. exception_str = "Signal ";
  674. exception_str += std::to_string(this->Signal);
  675. }
  676. #endif
  677. return exception_str;
  678. }