~ubuntu-branches/debian/sid/apt-dater/sid

« back to all changes in this revision

Viewing changes to src/glue.c

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2015-07-07 17:33:08 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20150707173308-7rkjhxnlq7gsykif
Tags: 1.0.2-1
* New upstream release.
  - Set the default of the opt-cmd-flags host option to "-t" since this is
    essential.
    Closes: #776392
  - Add new build dependency vim-common.
* Replace screen dependency with tmux.
* Create apt-dater group for session sharing.
* Add missing directories.
* Make the build reproducible.
  Closes: #789648
* Drop automake and autoconf build dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* apt-dater - terminal-based remote package update manager
 
2
 *
 
3
 * Authors:
 
4
 *   Thomas Liske <liske@ibh.de>
 
5
 *
 
6
 * Copyright Holder:
 
7
 *   2008-2015 (C) IBH IT-Service GmbH [https://www.ibh.de/apt-dater/]
 
8
 *
 
9
 * License:
 
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.
 
14
 *
 
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.
 
19
 *
 
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
 
23
 */
 
24
 
 
25
#include "apt-dater.h"
 
26
#include "glue.h"
 
27
 
 
28
#ifndef HAVE_GLIB_TIMEOUT_ADD_SECONDS
 
29
#warning Your glib2 does not support g_timeout_seconds (glib >= 2.13.5) - using glue code.
 
30
guint
 
31
g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) {
 
32
    g_timeout_add(interval*1000, function, data);
 
33
}
 
34
#endif
 
35
 
 
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:
 
39
 *
 
40
 * gspawn.[ch] - Process launching
 
41
 *
 
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.
 
45
 */
 
46
#include <sys/types.h>
 
47
#include <sys/wait.h>
 
48
gboolean
 
49
g_spawn_check_exit_status(gint exit_status, GError **error) {
 
50
  gboolean ret = FALSE;
 
51
 
 
52
  if (WIFEXITED (exit_status))
 
53
    {
 
54
      if (WEXITSTATUS (exit_status) != 0)
 
55
        {
 
56
          g_set_error (error, G_SPAWN_ERROR, WEXITSTATUS (exit_status),
 
57
                       _("Child process exited with code %ld"),
 
58
                       (long) WEXITSTATUS (exit_status));
 
59
          goto out;
 
60
        }
 
61
    }
 
62
  else if (WIFSIGNALED (exit_status))
 
63
    {
 
64
      g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
 
65
                   _("Child process killed by signal %ld"),
 
66
                   (long) WTERMSIG (exit_status));
 
67
      goto out;
 
68
    }
 
69
  else if (WIFSTOPPED (exit_status))
 
70
    {
 
71
      g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
 
72
                   _("Child process stopped by signal %ld"),
 
73
                   (long) WSTOPSIG (exit_status));
 
74
      goto out;
 
75
    }
 
76
  else
 
77
    {
 
78
      g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
 
79
                   _("Child process exited abnormally"));
 
80
      goto out;
 
81
    }
 
82
 
 
83
  ret = TRUE;
 
84
 out:
 
85
  return ret;
 
86
}
 
87
#endif