Retrieve and print detailed information using GetLastError() and
strerror().
This should be more useful to end-users than the current message (simply
“Error opening cmd pipe”) and might have helped us to solve
https://gitlab.com/openconnect/openconnect/-/issues/228 more quickly.
Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
sig_vpninfo = vpninfo;
sig_cmd_fd = openconnect_setup_cmd_pipe(vpninfo);
if (sig_cmd_fd < 0) {
- fprintf(stderr, _("Error opening cmd pipe\n"));
+#ifdef _WIN32
+ char *errstr = openconnect__win32_strerror(GetLastError());
+#else
+ const char *errstr = strerror(errno);
+#endif /* _WIN32 */
+ fprintf(stderr, _("Error opening cmd pipe: %s\n"), errstr);
+#ifdef _WIN32
+ free(errstr);
+#endif /* _WIN32 */
exit(1);
}
vpninfo->cmd_fd_internal = 1;