1
/* apt-dater - terminal-based remote package update manager
4
* Thomas Liske <liske@ibh.de>
7
* 2008-2015 (C) IBH IT-Service GmbH [https://www.ibh.de/apt-dater/]
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this package; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
#include "apt-dater.h"
28
#ifndef HAVE_GLIB_TIMEOUT_ADD_SECONDS
29
#warning Your glib2 does not support g_timeout_seconds (glib >= 2.13.5) - using glue code.
31
g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) {
32
g_timeout_add(interval*1000, function, data);
36
#ifndef HAVE_GLIB_SPAWN_CHECK_EXIT_STATUS
37
#warning Your glib2 does not support g_spawn_check_exit_status (glib >= 2.33.4) - using glue code.
38
/* Implementation has been taken from:
40
* gspawn.[ch] - Process launching
42
* Copyright 2000 Red Hat, Inc.
43
* g_execvpe implementation based on GNU libc execvp:
44
* Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
46
#include <sys/types.h>
49
g_spawn_check_exit_status(gint exit_status, GError **error) {
52
if (WIFEXITED (exit_status))
54
if (WEXITSTATUS (exit_status) != 0)
56
g_set_error (error, G_SPAWN_ERROR, WEXITSTATUS (exit_status),
57
_("Child process exited with code %ld"),
58
(long) WEXITSTATUS (exit_status));
62
else if (WIFSIGNALED (exit_status))
64
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
65
_("Child process killed by signal %ld"),
66
(long) WTERMSIG (exit_status));
69
else if (WIFSTOPPED (exit_status))
71
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
72
_("Child process stopped by signal %ld"),
73
(long) WSTOPSIG (exit_status));
78
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
79
_("Child process exited abnormally"));