diff options
author | cbdev <cb@cbcdn.com> | 2020-03-08 13:44:34 +0100 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2020-03-08 13:44:34 +0100 |
commit | aa5650c77af9379fc80c5329e0c0ffbe1f5d2355 (patch) | |
tree | dc5b231096d49827ad3bef26d9fd7e5cefac0a24 | |
parent | 87d7b5a81b8e8f05b4cb8cc79e38d33395b2189f (diff) | |
download | midimonster-aa5650c77af9379fc80c5329e0c0ffbe1f5d2355.tar.gz midimonster-aa5650c77af9379fc80c5329e0c0ffbe1f5d2355.tar.bz2 midimonster-aa5650c77af9379fc80c5329e0c0ffbe1f5d2355.zip |
Print proper error messages from core select on Windows
-rw-r--r-- | midimonster.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/midimonster.c b/midimonster.c index 2087c28..b8594b4 100644 --- a/midimonster.c +++ b/midimonster.c @@ -333,6 +333,9 @@ int main(int argc, char** argv){ managed_fd* signaled_fds = NULL; int rv = EXIT_FAILURE, error, maxfd = -1; char* cfg_file = DEFAULT_CFG; + #ifdef _WIN32 + char* error_message = NULL; + #endif //parse commandline arguments if(args_parse(argc, argv, &cfg_file)){ @@ -392,7 +395,15 @@ int main(int argc, char** argv){ tv = backend_timeout(); error = select(maxfd + 1, &read_fds, NULL, NULL, &tv); if(error < 0){ + #ifndef _WIN32 fprintf(stderr, "select failed: %s\n", strerror(errno)); + #else + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, WSAGetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error_message, 0, NULL); + fprintf(stderr, "select failed: %s\n", error_message); + LocalFree(error_message); + error_message = NULL; + #endif break; } |