Fix error message display if xdg-open fails

This commit is contained in:
Stéphane Lesimple
2025-04-14 21:02:36 +02:00
parent 0d7a8cc22b
commit 3a37673b3f

View File

@@ -45,16 +45,11 @@ static void send_errormsg(int fd, char *format, ...)
free(msg); free(msg);
} }
static int recv_errormsg(int fd, char **msg) static const char *recv_errormsg(int fd)
{ char buf[256]; { static char buf[256];
int n; if (read(fd, buf, 256))
return buf;
n = read(fd, buf, 256); return NULL;
if(!n) return n;
*msg = g_strdup(buf);
return n;
} }
#endif #endif
@@ -65,7 +60,7 @@ void GuiShowURL(char *target)
#if !defined(SYS_MINGW) && !defined(SYS_DARWIN) #if !defined(SYS_MINGW) && !defined(SYS_DARWIN)
pid_t pid; pid_t pid;
char *msg; const char *msg;
int err_pipe[2]; /* child may send down err msgs to us here */ int err_pipe[2]; /* child may send down err msgs to us here */
int result; int result;
#endif #endif
@@ -165,10 +160,10 @@ void GuiShowURL(char *target)
/* Parent process. See if some error condition came down the pipe. */ /* Parent process. See if some error condition came down the pipe. */
close(err_pipe[1]); close(err_pipe[1]);
result = recv_errormsg(err_pipe[0], &msg); msg = recv_errormsg(err_pipe[0]);
close(err_pipe[0]); close(err_pipe[0]);
if(result) if(msg)
{ GuiCreateMessage("%s", GTK_MESSAGE_ERROR, msg); { GuiCreateMessage("%s", GTK_MESSAGE_ERROR, msg);
} }
#endif #endif