Use kvm(3) instead of trying to get PIDs from /proc.
from and ok robert@
This commit is contained in:
parent
9d211806ce
commit
8954f27882
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.55 2010/12/14 09:54:17 ajacoutot Exp $
|
||||
# $OpenBSD: Makefile,v 1.56 2011/01/15 19:51:08 ajacoutot Exp $
|
||||
|
||||
COMMENT= powerful desktop search tool and indexer
|
||||
|
||||
@ -8,7 +8,7 @@ GNOME_VERSION= 0.8.17
|
||||
# there is already audio/tracker, so this port has to live
|
||||
# as meta-tracker.
|
||||
PKGNAME= meta-tracker-${VERSION}
|
||||
REVISION= 5
|
||||
REVISION= 6
|
||||
|
||||
EVO_VERSION= 2.32
|
||||
SUBST_VARS= EVO_VERSION
|
||||
|
@ -0,0 +1,15 @@
|
||||
$OpenBSD: patch-src_tracker-control_Makefile_in,v 1.1 2011/01/15 19:51:08 ajacoutot Exp $
|
||||
|
||||
Needed by patch-src_tracker-control_tracker-control_c.
|
||||
|
||||
--- src/tracker-control/Makefile.in.orig Sat Jan 15 18:20:58 2011
|
||||
+++ src/tracker-control/Makefile.in Sat Jan 15 18:21:08 2011
|
||||
@@ -122,7 +122,7 @@ CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
-CFLAGS = @CFLAGS@
|
||||
+CFLAGS = @CFLAGS@ -lkvm
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
@ -0,0 +1,124 @@
|
||||
$OpenBSD: patch-src_tracker-control_tracker-control_c,v 1.1 2011/01/15 19:51:08 ajacoutot Exp $
|
||||
|
||||
We don't use procfs in OpenBSD.
|
||||
|
||||
--- src/tracker-control/tracker-control.c.orig Thu Sep 2 14:51:00 2010
|
||||
+++ src/tracker-control/tracker-control.c Sat Jan 15 20:39:04 2011
|
||||
@@ -27,6 +27,16 @@
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
+#ifdef __OpenBSD__
|
||||
+#include <stdio.h>
|
||||
+#include <fcntl.h>
|
||||
+#include <limits.h>
|
||||
+#include <kvm.h>
|
||||
+#include <sys/param.h>
|
||||
+#include <sys/sysctl.h>
|
||||
+#include <sys/proc.h>
|
||||
+#endif
|
||||
+
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib/gprintf.h>
|
||||
@@ -101,6 +111,7 @@ static GOptionEntry entries[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
+#ifndef __OpenBSD__
|
||||
static GSList *
|
||||
get_pids (void)
|
||||
{
|
||||
@@ -137,6 +148,7 @@ get_pids (void)
|
||||
|
||||
return g_slist_reverse (pids);
|
||||
}
|
||||
+#endif
|
||||
|
||||
static void
|
||||
log_handler (const gchar *domain,
|
||||
@@ -298,46 +310,37 @@ main (int argc, char **argv)
|
||||
if (kill_option != TERM_NONE ||
|
||||
terminate_option != TERM_NONE ||
|
||||
(!start && !remove_config)) {
|
||||
- pids = get_pids ();
|
||||
- str = g_strdup_printf (g_dngettext (NULL,
|
||||
- "Found %d PID…",
|
||||
- "Found %d PIDs…",
|
||||
- g_slist_length (pids)),
|
||||
- g_slist_length (pids));
|
||||
- g_print ("%s\n", str);
|
||||
- g_free (str);
|
||||
|
||||
- for (l = pids; l; l = l->next) {
|
||||
- gchar *filename;
|
||||
- gchar *contents = NULL;
|
||||
- gchar **strv;
|
||||
+ gchar *basename, **strv;
|
||||
+ int i, nproc;
|
||||
+ struct kinfo_proc2 *plist, *kp;
|
||||
+ char buf[_POSIX2_LINE_MAX];
|
||||
+ kvm_t *kd;
|
||||
|
||||
- filename = g_build_filename ("/proc", l->data, "cmdline", NULL);
|
||||
- if (!g_file_get_contents (filename, &contents, NULL, &error)) {
|
||||
- str = g_strdup_printf (_("Could not open '%s'"), filename);
|
||||
- g_printerr ("%s, %s\n",
|
||||
- str,
|
||||
- error ? error->message : _("no error given"));
|
||||
- g_free (str);
|
||||
- g_clear_error (&error);
|
||||
- g_free (contents);
|
||||
- g_free (filename);
|
||||
+ if ((kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, buf)) == NULL) {
|
||||
+ printf("%s\n", buf);
|
||||
+ return EXIT_FAILURE;
|
||||
+ }
|
||||
|
||||
- continue;
|
||||
- }
|
||||
+ plist = kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof(*plist), &nproc);
|
||||
+ if (plist == NULL)
|
||||
+ return EXIT_FAILURE;
|
||||
|
||||
- strv = g_strsplit (contents, "^@", 2);
|
||||
- if (strv && strv[0]) {
|
||||
- gchar *basename;
|
||||
+ for (i = 0, kp = plist; i < nproc; i++, kp++) {
|
||||
+ if ((kp->p_flag & P_SYSTEM) != 0)
|
||||
+ continue;
|
||||
|
||||
- basename = g_path_get_basename (strv[0]);
|
||||
+ if ((strv = kvm_getargv2(kd, kp, 0)) == NULL)
|
||||
+ continue;
|
||||
|
||||
+ basename = g_path_get_basename(strv[0]);
|
||||
+
|
||||
if ((g_str_has_prefix (basename, "tracker") == TRUE ||
|
||||
g_str_has_prefix (basename, "lt-tracker") == TRUE) &&
|
||||
g_str_has_suffix (basename, "-control") == FALSE) {
|
||||
pid_t pid;
|
||||
|
||||
- pid = atoi (l->data);
|
||||
+ pid = kp->p_pid;
|
||||
str = g_strdup_printf (_("Found process ID %d for '%s'"), pid, basename);
|
||||
g_print ("%s\n", str);
|
||||
g_free (str);
|
||||
@@ -386,17 +389,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
-
|
||||
g_free (basename);
|
||||
}
|
||||
-
|
||||
- g_strfreev (strv);
|
||||
- g_free (contents);
|
||||
- g_free (filename);
|
||||
- }
|
||||
-
|
||||
- g_slist_foreach (pids, (GFunc) g_free, NULL);
|
||||
- g_slist_free (pids);
|
||||
}
|
||||
|
||||
if (hard_reset || soft_reset) {
|
Loading…
Reference in New Issue
Block a user