~ubuntu-branches/ubuntu/saucy/xfce4-power-manager/saucy-updates

« back to all changes in this revision

Viewing changes to debian/patches/0001-Solaris-specific-code-for-determining-the-start-time.patch

  • Committer: Package Import Robot
  • Author(s): Lionel Le Folgoc
  • Date: 2012-04-03 22:15:05 UTC
  • mfrom: (2.3.8)
  • Revision ID: package-import@ubuntu.com-20120403221505-2dvza7w2d97zb7qn
Tags: 1.0.11-0ubuntu1
* New upstream bugfix release.
* debian/patches:
  - 0001-Solaris-specific-code-for-determining-the-start-time.patch,
    02_fix-notify-detect.patch,
    07_fix_broken_empty_icon_battery.patch: dropped, included upstream.
  - xubuntu_fix-status-icon-other-devices.patch: refreshed to apply cleanly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 47b7e20d7acd2cc64caf379eb6cd385705d3e90d Mon Sep 17 00:00:00 2001
2
 
From: Guido Berhoerster <gber@openindiana.org>
3
 
Date: Mon, 28 Mar 2011 17:19:40 +0200
4
 
Subject: [PATCH] Solaris-specific code for determining the start time of a
5
 
 process.
6
 
 
7
 
Solaris also allows to obtain this information through procfs,
8
 
however design and implementation differ vastly from Linux.
9
 
---
10
 
 src/xfpm-polkit.c |   40 +++++++++++++++++++++++++++++++++++-----
11
 
 1 files changed, 35 insertions(+), 5 deletions(-)
12
 
 
13
 
diff --git a/src/xfpm-polkit.c b/src/xfpm-polkit.c
14
 
index a50c2db..29fcf7d 100644
15
 
--- a/src/xfpm-polkit.c
16
 
+++ b/src/xfpm-polkit.c
17
 
@@ -32,12 +32,15 @@
18
 
 
19
 
 #include <sys/types.h>
20
 
 
21
 
-#if defined(__FreeBSD__)
22
 
-#include <sys/stat.h>
23
 
-#else
24
 
+#if defined(__linux)
25
 
 #include <sys/param.h>
26
 
 #include <sys/sysctl.h>
27
 
 #include <sys/user.h>
28
 
+#elif defined(__FreeBSD__)
29
 
+#include <sys/stat.h>
30
 
+#elif defined(__SVR4) || defined(__sun)
31
 
+#include <fcntl.h>
32
 
+#include <procfs.h>
33
 
 #endif
34
 
 
35
 
 #include <errno.h>
36
 
@@ -115,7 +118,7 @@ static guint64
37
 
 get_start_time_for_pid (pid_t pid)
38
 
 {
39
 
     guint64 start_time;
40
 
-#if !defined(__FreeBSD__)
41
 
+#if defined(__linux)
42
 
     gchar *filename;
43
 
     gchar *contents;
44
 
     size_t length;
45
 
@@ -172,7 +175,7 @@ get_start_time_for_pid (pid_t pid)
46
 
     g_free (filename);
47
 
     g_free (contents);
48
 
     
49
 
-#else /*if !defined(__FreeBSD__)*/
50
 
+#elif defined(__FreeBSD__)
51
 
 
52
 
     struct kinfo_proc p;
53
 
     
54
 
@@ -189,6 +192,33 @@ get_start_time_for_pid (pid_t pid)
55
 
     start_time = (guint64) p.ki_start.tv_sec;
56
 
     
57
 
 out:
58
 
+#elif defined(__SVR4) || defined(__sun)
59
 
+
60
 
+    psinfo_t p;
61
 
+    gchar *filename;
62
 
+    int fd;
63
 
+
64
 
+    start_time = 0;
65
 
+
66
 
+    filename = g_strdup_printf ("/proc/%d/psinfo", (int) pid);
67
 
+    if ((fd = open(filename, O_RDONLY)) < 0)
68
 
+    {
69
 
+       g_warning ("Error opening %s (%s)",
70
 
+                  filename,
71
 
+                  g_strerror (errno));
72
 
+       goto out;
73
 
+    }
74
 
+    if (read(fd, &p, sizeof (p)) != sizeof (p))
75
 
+    {
76
 
+       g_warning ("Error reading %s",
77
 
+                  filename);
78
 
+       close(fd);
79
 
+       goto out;
80
 
+    }
81
 
+    start_time = (guint64) p.pr_start.tv_sec;
82
 
+    close(fd);
83
 
+out:
84
 
+    g_free (filename);
85
 
 #endif
86
 
     
87
 
     return start_time;
88
 
1.7.4.4
89