| 195 | #else /* WIN32 */ |
| 196 | |
| 197 | static BOOL WINAPI |
| 198 | consoleHandler(DWORD dwCtrlType) |
| 199 | { |
| 200 | char errbuf[256]; |
| 201 | |
| 202 | if (dwCtrlType == CTRL_C_EVENT || |
| 203 | dwCtrlType == CTRL_BREAK_EVENT) |
| 204 | { |
| 205 | CancelRequested = true; |
| 206 | |
| 207 | if (cancel_callback != NULL) |
| 208 | cancel_callback(); |
| 209 | |
| 210 | /* Send QueryCancel if we are processing a database query */ |
| 211 | EnterCriticalSection(&cancelConnLock); |
| 212 | if (cancelConn != NULL) |
| 213 | { |
| 214 | if (PQcancel(cancelConn, errbuf, sizeof(errbuf))) |
| 215 | { |
| 216 | write_stderr(cancel_sent_msg); |
| 217 | } |
| 218 | else |
| 219 | { |
| 220 | write_stderr(cancel_not_sent_msg); |
| 221 | write_stderr(errbuf); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | LeaveCriticalSection(&cancelConnLock); |
| 226 | |
| 227 | return TRUE; |
| 228 | } |
| 229 | else |
| 230 | /* Return FALSE for any signals not being handled */ |
| 231 | return FALSE; |
| 232 | } |
| 233 | |
| 234 | void |
| 235 | setup_cancel_handler(void (*callback) (void)) |
nothing calls this directly
no test coverage detected