* handle_sigint * * Handle interrupt signals by canceling the current command, if cancelConn * is set. */
| 150 | * is set. |
| 151 | */ |
| 152 | static void |
| 153 | handle_sigint(SIGNAL_ARGS) |
| 154 | { |
| 155 | int save_errno = errno; |
| 156 | char errbuf[256]; |
| 157 | |
| 158 | CancelRequested = true; |
| 159 | |
| 160 | if (cancel_callback != NULL) |
| 161 | cancel_callback(); |
| 162 | |
| 163 | /* Send QueryCancel if we are processing a database query */ |
| 164 | if (cancelConn != NULL) |
| 165 | { |
| 166 | if (PQcancel(cancelConn, errbuf, sizeof(errbuf))) |
| 167 | { |
| 168 | write_stderr(cancel_sent_msg); |
| 169 | } |
| 170 | else |
| 171 | { |
| 172 | write_stderr(cancel_not_sent_msg); |
| 173 | write_stderr(errbuf); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | errno = save_errno; /* just in case the write changed it */ |
| 178 | } |
| 179 | |
| 180 | /* |
| 181 | * setup_cancel_handler |
nothing calls this directly
no test coverage detected