[dpkg] 97/187: s-s-d: Port process handling to AIX

Reiner Herrmann reiner at reiner-h.de
Sun Nov 6 12:46:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

deki-guest pushed a commit to branch master
in repository dpkg.

commit e12ad320d4c073016d77acefdb71ebf4e34b82be
Author: Guillem Jover <guillem at debian.org>
Date:   Sat Aug 27 17:38:50 2016 +0200

    s-s-d: Port process handling to AIX
---
 configure.ac              |  1 +
 debian/changelog          |  1 +
 utils/start-stop-daemon.c | 77 +++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 76 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index bf0d37e..2012f6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,7 @@ AC_CHECK_HEADERS([\
   sys/syscall.h \
   sys/user.h \
   sys/proc.h \
+  sys/procfs.h \
   sys/pstat.h \
   linux/fiemap.h \
 ])
diff --git a/debian/changelog b/debian/changelog
index 27d223c..6d55ee6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -42,6 +42,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
       do_procinit().
     - Port start-stop-daemon process handling to Mac OS X.
       Based on a patch by Mo McRoberts <mo at nevali.net>.
+    - Port start-stop-daemon process handling to AIX.
   * Perl modules:
     - Obsolete Source-Version substvar in Dpkg::Substvars by emitting errors.
     - Rework keyring hooks in Dpkg::Vendor. Deprecate the keyrings hook, and
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 398707d..4b08403 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -41,6 +41,8 @@
 #  define OS_Darwin
 #elif defined(__sun)
 #  define OS_Solaris
+#elif defined(_AIX)
+#  define OS_AIX
 #elif defined(__hpux)
 #  define OS_HPUX
 #else
@@ -56,6 +58,9 @@
 #ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
 #endif
+#ifdef HAVE_SYS_PROCFS_H
+#include <sys/procfs.h>
+#endif
 #ifdef HAVE_SYS_PROC_H
 #include <sys/proc.h>
 #endif
@@ -133,6 +138,9 @@
 #define PROCESS_NAME_SIZE 15
 #elif defined(OS_Darwin)
 #define PROCESS_NAME_SIZE 16
+#elif defined(OS_AIX)
+/* This comes from PRFNSZ defined in AIX's <sys/procfs.h>. */
+#define PROCESS_NAME_SIZE 16
 #elif defined(OS_NetBSD)
 #define PROCESS_NAME_SIZE 16
 #elif defined(OS_OpenBSD)
@@ -1267,9 +1275,25 @@ proc_status_field(pid_t pid, const char *field)
 
 	return value;
 }
-#endif
+#elif defined(OS_AIX)
+static bool
+proc_get_psinfo(pid_t pid, struct psinfo *psinfo)
+{
+	char filename[64];
+	FILE *fp;
 
-#if defined(OS_Hurd)
+	sprintf(filename, "/proc/%d/psinfo", pid);
+	fp = fopen(filename, "r");
+	if (!fp)
+		return false;
+	if (fread(psinfo, sizeof(*psinfo), 1, fp) == 0)
+		return false;
+	if (ferror(fp))
+		return false;
+
+	return true;
+}
+#elif defined(OS_Hurd)
 static void
 init_procset(void)
 {
@@ -1372,6 +1396,20 @@ pid_is_exec(pid_t pid, const struct stat *esb)
 
 	return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino);
 }
+#elif defined(OS_AIX)
+static bool
+pid_is_exec(pid_t pid, const struct stat *esb)
+{
+	struct stat sb;
+	char filename[64];
+
+	sprintf(filename, "/proc/%d/object/a.out", pid);
+
+	if (stat(filename, &sb) != 0)
+		return false;
+
+	return sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino;
+}
 #elif defined(OS_Hurd)
 static bool
 pid_is_exec(pid_t pid, const struct stat *esb)
@@ -1539,6 +1577,17 @@ pid_is_child(pid_t pid, pid_t ppid)
 
 	return (pid_t)info.pbi_ppid == ppid;
 }
+#elif defined(OS_AIX)
+static bool
+pid_is_child(pid_t pid, pid_t ppid)
+{
+	struct psinfo psi;
+
+	if (!proc_get_psinfo(pid, &psi))
+		return false;
+
+	return (pid_t)psi.pr_ppid == ppid;
+}
 #elif defined(OS_HPUX)
 static bool
 pid_is_child(pid_t pid, pid_t ppid)
@@ -1637,6 +1686,17 @@ pid_is_user(pid_t pid, uid_t uid)
 
 	return info.pbi_ruid == uid;
 }
+#elif defined(OS_AIX)
+static bool
+pid_is_user(pid_t pid, uid_t uid)
+{
+	struct psinfo psi;
+
+	if (!proc_get_psinfo(pid, &psi))
+		return false;
+
+	return psi.pr_uid == uid;
+}
 #elif defined(OS_HPUX)
 static bool
 pid_is_user(pid_t pid, uid_t uid)
@@ -1749,6 +1809,17 @@ pid_is_cmd(pid_t pid, const char *name)
 
 	return false;
 }
+#elif defined(OS_AIX)
+static bool
+pid_is_cmd(pid_t pid, const char *name)
+{
+	struct psinfo psi;
+
+	if (!proc_get_psinfo(pid, &psi))
+		return false;
+
+	return strcmp(psi.pr_fname, name) == 0;
+}
 #elif defined(OS_HPUX)
 static bool
 pid_is_cmd(pid_t pid, const char *name)
@@ -1892,7 +1963,7 @@ do_pidfile(const char *name)
 		fatal("unable to open pidfile %s", name);
 }
 
-#if defined(OS_Linux) || defined(OS_Solaris)
+#if defined(OS_Linux) || defined(OS_Solaris) || defined(OS_AIX)
 static enum status_code
 do_procinit(void)
 {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list