Skip to content

Commit 31ade88

Browse files
committed
bug.cpp: use std::{signal,system}
1 parent 99decc1 commit 31ade88

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/TiledArray/util/bug.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ static void handler(int sig) {
105105
void Debugger::handle(int sig) {
106106
if (sig >= NSIG) return;
107107
typedef void (*handler_type)(int);
108-
signal(sig, (handler_type)handler);
108+
std::signal(sig, (handler_type)handler);
109109
signals[sig] = this;
110110
mysigs_[sig] = 1;
111111
}
112112

113113
void Debugger::release(int sig) {
114114
if (sig >= NSIG) return;
115-
signal(sig, SIG_DFL);
115+
std::signal(sig, SIG_DFL);
116116
signals[sig] = nullptr;
117117
mysigs_[sig] = 0;
118118
}
@@ -231,7 +231,6 @@ void Debugger::debug(const char *reason) {
231231
std::cout << "no reason given";
232232
std::cout << std::endl;
233233

234-
235234
const std::string cmd = replace_macros(cmd_);
236235
// start the debugger
237236
// before starting the debugger de-register signal handler for SIGTRAP to
@@ -240,13 +239,13 @@ void Debugger::debug(const char *reason) {
240239
int system_retvalue = 0;
241240
if (!cmd.empty()) {
242241
std::cout << prefix_ << "Debugger: starting \"" << cmd << "\"" << std::endl;
243-
system_retvalue = system(cmd.c_str());
242+
system_retvalue = std::system(cmd.c_str());
244243
}
245244
if (system_retvalue != 0) {
246245
std::cout << prefix_
247-
<< "Failed debugger launch: system() did not succeed ..."
248-
<< std::endl;
249-
} else { // call to system() succeeded
246+
<< "Failed debugger launch: system() did not succeed ..."
247+
<< std::endl;
248+
} else { // call to system() succeeded
250249
// wait until the debugger is ready
251250
if (sleep_) {
252251
std::cout << prefix_ << "Debugger: sleeping " << sleep_
@@ -257,17 +256,17 @@ void Debugger::debug(const char *reason) {
257256
std::cout << prefix_ << "Debugger: waiting for the user ...";
258257
if (cmd_.find(" gdb ") != std::string::npos ||
259258
cmd_.find(" lldb ") != std::string::npos) {
260-
std::cout <<
261-
" configure debugging session (set breakpoints/watchpoints, "
262-
"etc.) then type 'c' to continue running";
259+
std::cout
260+
<< " configure debugging session (set breakpoints/watchpoints, "
261+
"etc.) then type 'c' to continue running";
263262
} else if (cmd.empty()) {
264-
std::cout << " attach debugger to process "
265-
<< std::to_string(getpid())
263+
std::cout << " attach debugger to process " << std::to_string(getpid())
266264
<< " as follows:" << std::endl
267-
<< prefix_ << "Debugger: - if using gdb: "
268-
<< replace_macros(gdb_cmd_) << std::endl
269-
<< prefix_ << "Debugger: - if using lldb: "
270-
<< replace_macros(lldb_cmd_);
265+
<< prefix_
266+
<< "Debugger: - if using gdb: " << replace_macros(gdb_cmd_)
267+
<< std::endl
268+
<< prefix_
269+
<< "Debugger: - if using lldb: " << replace_macros(lldb_cmd_);
271270
}
272271
std::cout << std::endl;
273272

@@ -299,7 +298,7 @@ void Debugger::got_signal(int sig) {
299298
else
300299
signame = "UNKNOWN SIGNAL";
301300

302-
for (auto const &action: actions_) {
301+
for (auto const &action : actions_) {
303302
action();
304303
}
305304
actions_.clear();

0 commit comments

Comments
 (0)