| 163 | } |
| 164 | |
| 165 | void daemon_maybe_debug(char *argv[]) |
| 166 | { |
| 167 | #if DEVELOPER |
| 168 | for (int i = 1; argv[i]; i++) { |
| 169 | if (!streq(argv[i], "--debugger")) |
| 170 | continue; |
| 171 | |
| 172 | /* Don't let this mess up stdout, so redir to /dev/null */ |
| 173 | char *cmd = tal_fmt(NULL, "${DEBUG_TERM:-gnome-terminal --} gdb -ex 'attach %u' %s >/dev/null &", getpid(), argv[0]); |
| 174 | fprintf(stderr, "Running %s\n", cmd); |
| 175 | /* warn_unused_result is fascist bullshit. |
| 176 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */ |
| 177 | if (system(cmd)) |
| 178 | ; |
| 179 | tal_free(cmd); |
| 180 | /* Continue in the debugger. */ |
| 181 | kill(getpid(), SIGSTOP); |
| 182 | } |
| 183 | #endif /* DEVELOPER */ |
| 184 | } |
no test coverage detected