diff --git a/configure.ac b/configure.ac index 70167605..a6a329ba 100644 --- a/configure.ac +++ b/configure.ac @@ -122,7 +122,7 @@ AS_IF([test "x$ac_cv_member_struct_dirent_d_ino" != "xyes"], # we need these -AC_CHECK_FUNCS([memset memcpy realpath setlocale strerror getpass]) +AC_CHECK_FUNCS([memset memcpy realpath setlocale strerror getpass setsid]) AC_CHECK_FUNC(timegm,[],[AC_MSG_ERROR([missing required function timegm])]) # require pkg-config diff --git a/lib/mu-util.c b/lib/mu-util.c index 37d0e936..367ad78d 100644 --- a/lib/mu-util.c +++ b/lib/mu-util.c @@ -1,7 +1,7 @@ /* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/ /* ** -** Copyright (C) 2008-2013 Dirk-Jan C. Binnema +** Copyright (C) 2008-2016 Dirk-Jan C. Binnema ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -330,6 +330,17 @@ mu_util_program_in_path (const char *prog) } +/* + * Set the child to a group leader to avoid being killed when the + * parent group is killed. + */ +static void +maybe_setsid (G_GNUC_UNUSED gpointer user_data) +{ +#if HAVE_SETSID + setsid(); +#endif /*HAVE_SETSID*/ +} gboolean mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote, @@ -366,8 +377,8 @@ mu_util_play (const char *path, gboolean allow_local, gboolean allow_remote, err = NULL; rv = g_spawn_async (NULL, (gchar**)&argv, NULL, - G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, - err); + G_SPAWN_SEARCH_PATH, maybe_setsid, + NULL, NULL, err); return rv; }