* robustness/cleanup fixes:
- mu-util.c: don't raise errors when fputs failes (this would spam us when a
pipe broke)
- mu-cmd-server.c: handle SIGPIPE, ignore empty command lines
This commit is contained in:
@ -431,12 +431,7 @@ mu_util_fputs_encoded (const char *str, FILE *stream)
|
|||||||
g_free (conv);
|
g_free (conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv == EOF) { /* note, apparently, does not set errno */
|
return (rv == EOF) ? FALSE : TRUE;
|
||||||
g_warning ("%s: fputs failed", __FUNCTION__);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@ static void
|
|||||||
install_sig_handler (void)
|
install_sig_handler (void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
int i, sigs[] = { SIGINT, SIGHUP, SIGTERM };
|
int i, sigs[] = { SIGINT, SIGHUP, SIGTERM, SIGPIPE };
|
||||||
|
|
||||||
MU_TERMINATE = FALSE;
|
MU_TERMINATE = FALSE;
|
||||||
|
|
||||||
@ -123,15 +123,18 @@ print_expr (const char* frm, ...)
|
|||||||
* COOKIE_PRE <len-of-following-sexp-in-hex> COOKIE_POST
|
* COOKIE_PRE <len-of-following-sexp-in-hex> COOKIE_POST
|
||||||
*/
|
*/
|
||||||
rv = write (outfd, cookie, lenlen + 2);
|
rv = write (outfd, cookie, lenlen + 2);
|
||||||
if (rv != -1)
|
if (rv != -1) {
|
||||||
rv = write (outfd, expr, exprlen);
|
rv = write (outfd, expr, exprlen);
|
||||||
|
g_free (expr);
|
||||||
|
}
|
||||||
if (rv != -1)
|
if (rv != -1)
|
||||||
rv = write (outfd, "\n", 1);
|
rv = write (outfd, "\n", 1);
|
||||||
if (rv == -1)
|
if (rv == -1) {
|
||||||
g_warning ("%s: write() failed: %s",
|
g_critical ("%s: write() failed: %s",
|
||||||
__FUNCTION__, strerror(errno));
|
__FUNCTION__, strerror(errno));
|
||||||
|
/* terminate ourselves */
|
||||||
g_free (expr);
|
raise (SIGTERM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1351,6 +1354,11 @@ handle_args (MuStore *store, MuQuery *query, GSList *args, GError **err)
|
|||||||
};
|
};
|
||||||
|
|
||||||
cmd = (const char*) args->data;
|
cmd = (const char*) args->data;
|
||||||
|
|
||||||
|
/* ignore empty */
|
||||||
|
if (strlen (cmd) == 0)
|
||||||
|
return MU_OK;
|
||||||
|
|
||||||
for (u = 0; u != G_N_ELEMENTS (cmd_map); ++u)
|
for (u = 0; u != G_N_ELEMENTS (cmd_map); ++u)
|
||||||
if (g_strcmp0(cmd, cmd_map[u].cmd) == 0)
|
if (g_strcmp0(cmd, cmd_map[u].cmd) == 0)
|
||||||
return cmd_map[u].func (store, query,
|
return cmd_map[u].func (store, query,
|
||||||
|
|||||||
Reference in New Issue
Block a user