~noskcaj/ubuntu/vivid/gdm/3.14.1

« back to all changes in this revision

Viewing changes to common/gdm-crash-logger.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha, Tim Lunn, Jeremy Bicha, Robert Ancell
  • Date: 2013-05-31 22:36:08 UTC
  • mfrom: (1.4.55)
  • Revision ID: package-import@ubuntu.com-20130531223608-33uo85niksee5460
Tags: 3.8.1.1-0ubuntu1
[ Tim Lunn ]
* New upstream release
* debian/patches/ubuntu_dont_catch_sigsegv.patch:
  - Dropped, obsolete
* debian/rules:
  - Don't rename gdm binary since that's already been
    done in the new version

[ Jeremy Bicha ]
* debian/control.in: Bump minimum glib
* debian/watch: Watch for unstable releases
* debian/patches/00git_logind_check.patch:
  - Dropped, applied in new release
* debian/patches/08_frequent-users_greeter.patch: Refreshed

[ Robert Ancell ]
* New upstream release
* debian/patches/ubuntu_daemon_autologin_tracking.patch:
* debian/patches/ubuntu_ensure_dirs.patch:
* debian/patches/ubuntu_slave-only-set-up-autologin.patch:
  - Applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2
 
 *
3
 
 * Dan Williams <dcbw@redhat.com>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
 
 *
19
 
 * (C) Copyright 2006 Red Hat, Inc.
20
 
 */
21
 
 
22
 
#include "config.h"
23
 
 
24
 
#include <stdio.h>
25
 
#include <unistd.h>
26
 
#include <errno.h>
27
 
#include <sys/wait.h>
28
 
#include <stdlib.h>
29
 
#include <syslog.h>
30
 
#include <glib.h>
31
 
 
32
 
int main (int argc, char ** argv)
33
 
{
34
 
        GPid            gdb_pid;
35
 
        int             out;
36
 
        char            gdm_pid[16];
37
 
        char            line[256];
38
 
        int             gdb_stat;
39
 
        int             bytes_read;
40
 
        gboolean        res;
41
 
        gboolean        done;
42
 
        GError         *error;
43
 
        int             options;
44
 
        char *  args[] = { "gdb",
45
 
                           "--batch",
46
 
                           "--quiet",
47
 
                           "--command=" DATADIR "/gdm/gdb-cmd",
48
 
                           NULL,
49
 
                           NULL };
50
 
 
51
 
        snprintf (gdm_pid, sizeof (gdm_pid), "--pid=%d", getppid ());
52
 
        args[4] = &gdm_pid[0];
53
 
        error = NULL;
54
 
        res = g_spawn_async_with_pipes (NULL,
55
 
                                        args,
56
 
                                        NULL,
57
 
                                        G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
58
 
                                        NULL,
59
 
                                        NULL,
60
 
                                        &gdb_pid,
61
 
                                        NULL,
62
 
                                        &out,
63
 
                                        NULL,
64
 
                                        &error);
65
 
        if (! res) {
66
 
                g_warning ("Unable to get backtrace: %s", error->message);
67
 
                g_error_free (error);
68
 
                exit (1);
69
 
        }
70
 
 
71
 
        options = LOG_PID | LOG_CONS;
72
 
#ifdef LOG_PERROR
73
 
        options |= LOG_PERROR;
74
 
#endif
75
 
 
76
 
        openlog ("gdm", options, LOG_DAEMON);
77
 
        syslog (LOG_CRIT, "******************* START **********************************");
78
 
        done = FALSE;
79
 
        while (!done) {
80
 
                bytes_read = read (out, line, sizeof (line) - 1);
81
 
                if (bytes_read > 0) {
82
 
                        char *end = &line[0];
83
 
                        char *start = &line[0];
84
 
 
85
 
                        /* Can't just funnel the output to syslog, have to do a separate
86
 
                         * syslog () for each line in the output.
87
 
                         */
88
 
                        line[bytes_read] = '\0';
89
 
                        while (*end != '\0') {
90
 
                                if (*end == '\n') {
91
 
                                        *end = '\0';
92
 
                                        syslog (LOG_CRIT, "%s", start);
93
 
                                        start = end + 1;
94
 
                                }
95
 
                                end++;
96
 
                        }
97
 
                } else if ((bytes_read <= 0) || ((errno != EINTR) && (errno != EAGAIN))) {
98
 
                        done = TRUE;
99
 
                }
100
 
        }
101
 
        syslog (LOG_CRIT, "******************* END **********************************");
102
 
        close (out);
103
 
        waitpid (gdb_pid, &gdb_stat, 0);
104
 
        exit (0);
105
 
}