cmProcess.cxx 18 KB

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