Child processes should be session leaders.

If not, when the session of mu is killed, these child processes are also
killed. This scenario shows up when using mu4e: a PDF attachment, for
example, is opened by Evince, but as soon as Emacs exits, Evince is also
killed.
This commit is contained in:
Hong Xu 2016-12-07 17:55:28 -08:00 committed by djcb
parent f49e808160
commit 887e75c4ee
2 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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 <djcb@djcbsoftware.nl>
** Copyright (C) 2008-2016 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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;
}