3
* Copyright 2013 Canonical Ltd.
5
* This program is free software: you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 3, as published
7
* by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranties of
11
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
* Ted Gould <ted.gould@canonical.com>
24
main (int argc, char * argv[])
26
const gchar * job = g_getenv("JOB");
27
g_return_val_if_fail(job != NULL, -1);
29
const gchar * instance = g_getenv("INSTANCE");
30
g_return_val_if_fail(instance != NULL, -1);
32
gboolean crashed = FALSE;
33
if (g_getenv("EXIT_STATUS") != NULL || g_getenv("EXIT_SIGNAL") != NULL) {
37
gchar * appid = g_strdup(instance);
38
if (g_strcmp0(job, "application-legacy") == 0) {
39
gchar * lasthyphenstanding = g_strrstr(appid, "-");
40
if (lasthyphenstanding != NULL) {
41
lasthyphenstanding[0] = '\0';
43
g_warning("Legacy job instance '%s' is missing a hyphen", appid);
47
GDBusConnection * bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
48
g_return_val_if_fail(bus != NULL, -1);
50
GError * error = NULL;
51
g_dbus_connection_emit_signal(bus,
52
NULL, /* destination */
54
"com.canonical.UpstartAppLaunch",
56
g_variant_new("(ss)", appid, crashed ? "crash" : "start-failure"),
59
g_debug("Emitting failed event '%s' for app '%s'", crashed ? "crash" : "start-failure", appid);
62
g_warning("Unable to emit signal: %s", error->message);
67
g_dbus_connection_flush_sync(bus, NULL, NULL);