Skip to content

Commit

Permalink
Merge pull request #3203 from dbnicholson/version-sigpipe
Browse files Browse the repository at this point in the history
main: Ignore SIGPIPE when printing version
  • Loading branch information
cgwalters committed Feb 27, 2024
2 parents 1b3ffe5 + 422a288 commit 1a54d94
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ostree/ot-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <gio/gio.h>

#include <locale.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
Expand Down Expand Up @@ -510,6 +511,11 @@ ostree_option_context_parse (GOptionContext *context, const GOptionEntry *main_e

if (opt_version)
{
/* Ignore SIGPIPE so that piping the output to grep or similar
* doesn't cause the process to fail. */
if (signal (SIGPIPE, SIG_IGN) == SIG_ERR)
return glnx_throw_errno_prefix (error, "Ignoring SIGPIPE");

/* This should now be YAML, like `docker version`, so it's both nice to read
* possible to parse */
g_auto (GStrv) features = g_strsplit (OSTREE_FEATURES, " ", -1);
Expand Down

0 comments on commit 1a54d94

Please sign in to comment.