summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2019-11-13 21:12:48 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2019-11-15 15:39:31 +0100
commit6df0bb7d382fa7a6043fc7e9587889d3b53976b7 (patch)
treee0fa65ed84199f0f62b097c3e481a550def6c4bc /extra
parent89ae01fd0085cf0d1af272eca545e49fdadf4538 (diff)
downloadmariadb-git-6df0bb7d382fa7a6043fc7e9587889d3b53976b7.tar.gz
MDEV-21062 Buildbot, Windows - sporadically missing lines from mtr's "exec"
Provide own version of popen/pclose, in attempt to workaround sporadic erratic behavior of UCRT's one.
Diffstat (limited to 'extra')
-rw-r--r--extra/perror.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/extra/perror.c b/extra/perror.c
index e3db7b951b7..afbd734ce16 100644
--- a/extra/perror.c
+++ b/extra/perror.c
@@ -199,19 +199,22 @@ int get_ER_error_msg(uint code, const char **name_ptr, const char **msg_ptr)
return 0;
}
-#if defined(__WIN__)
+#if defined(_WIN32)
static my_bool print_win_error_msg(DWORD error, my_bool verbose)
{
- LPTSTR s;
- if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ char *s;
+ if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, error, 0, (LPTSTR)&s, 0,
+ NULL, error, 0, (char *)&s, 0,
NULL))
{
+ char* end = s + strlen(s) - 1;
+ while (end > s && (*end == '\r' || *end == '\n'))
+ *end-- = 0;
if (verbose)
- printf("Win32 error code %lu: %s", error, s);
+ printf("Win32 error code %lu: %s\n", error, s);
else
- puts(s);
+ printf("%s\n",s);
LocalFree(s);
return 0;
}
@@ -259,7 +262,7 @@ int main(int argc,char *argv[])
const char *msg;
const char *name;
char *unknown_error = 0;
-#if defined(__WIN__)
+#if defined(_WIN32)
my_bool skip_win_message= 0;
#endif
MY_INIT(argv[0]);
@@ -350,17 +353,17 @@ int main(int argc,char *argv[])
}
if (!found)
{
-#if defined(__WIN__)
+#if defined(_WIN32)
if (!(skip_win_message= !print_win_error_msg((DWORD)code, verbose)))
{
#endif
fprintf(stderr,"Illegal error code: %d\n",code);
error=1;
-#if defined(__WIN__)
+#if defined(_WIN32)
}
#endif
}
-#if defined(__WIN__)
+#if defined(_WIN32)
if (!skip_win_message)
print_win_error_msg((DWORD)code, verbose);
#endif