110 lines
2.4 KiB
Diff
110 lines
2.4 KiB
Diff
W00T, AIX does have /proc filesystem - even with slightly different layout.
|
|
|
|
--- src/start-stop-daemon.c
|
|
+++ src/start-stop-daemon.c
|
|
@@ -56,6 +56,8 @@
|
|
# define OSNetBSD
|
|
#elif defined(__APPLE__)
|
|
# define OSDarwin
|
|
+#elif defined(_AIX)
|
|
+# define OSaix
|
|
#else
|
|
# error Unknown architecture - cannot build start-stop-daemon
|
|
#endif
|
|
@@ -85,6 +87,10 @@
|
|
#include <sys/pstat.h>
|
|
#endif
|
|
|
|
+#if defined(OSaix)
|
|
+#include <sys/procfs.h>
|
|
+#endif
|
|
+
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
@@ -178,7 +184,7 @@
|
|
static void do_pidfile(const char *name);
|
|
static void do_stop(int signal_nr, int quietmode,
|
|
int *n_killed, int *n_notkilled, int retry_nr);
|
|
-#if defined(OSLinux) || defined(OShpux)
|
|
+#if defined(OSLinux) || defined(OShpux) || defined(OSaix)
|
|
static int pid_is_exec(pid_t pid, const struct stat *esb);
|
|
#endif
|
|
|
|
@@ -755,7 +761,7 @@
|
|
static void
|
|
check(pid_t pid)
|
|
{
|
|
-#if defined(OSLinux) || defined(OShpux)
|
|
+#if defined(OSLinux) || defined(OShpux) || defined(OSaix)
|
|
if (execname && !pid_is_exec(pid, &exec_stat))
|
|
return;
|
|
#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin)
|
|
@@ -791,7 +797,7 @@
|
|
/* WTA: this needs to be an autoconf check for /proc/pid existance.
|
|
*/
|
|
|
|
-#if defined(OSLinux) || defined (OSsunos) || defined(OSfreebsd)
|
|
+#if defined(OSLinux) || defined (OSsunos) || defined(OSfreebsd) || defined(OSaix)
|
|
static void
|
|
do_procinit(void)
|
|
{
|
|
@@ -1059,6 +1065,58 @@
|
|
}
|
|
#endif /* OShpux */
|
|
|
|
+#if defined(OSaix)
|
|
+/* max possible pid (signed long) in theory:
|
|
+ * 32bit: 2147483647 (10 digits)
|
|
+ * 64bit: 9223372036854775807 (19 digits)
|
|
+ */
|
|
+static int
|
|
+pid_is_exec(pid_t pid, const struct stat *esb)
|
|
+{
|
|
+ struct stat sb;
|
|
+ char buf[40];
|
|
+
|
|
+ sprintf(buf, "/proc/%ld/object/a.out", pid);
|
|
+ if (stat(buf, &sb) != 0)
|
|
+ return 0;
|
|
+ return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino);
|
|
+}
|
|
+
|
|
+
|
|
+static int
|
|
+pid_is_user(pid_t pid, uid_t uid)
|
|
+{
|
|
+ struct stat sb;
|
|
+ char buf[32];
|
|
+
|
|
+ sprintf(buf, "/proc/%ld", pid);
|
|
+ if (stat(buf, &sb) != 0)
|
|
+ return 0;
|
|
+ return (sb.st_uid == uid);
|
|
+}
|
|
+
|
|
+
|
|
+static int
|
|
+pid_is_cmd(pid_t pid, const char *name)
|
|
+{
|
|
+ char buf[40];
|
|
+ FILE *f;
|
|
+ struct psinfo psi;
|
|
+ int r;
|
|
+
|
|
+ sprintf(buf, "/proc/%ld/psinfo", pid);
|
|
+ f = fopen(buf, "r");
|
|
+ if (!f)
|
|
+ return 0;
|
|
+ r = fread(&psi, sizeof(psi), 1, f);
|
|
+ fclose(f);
|
|
+ if (r != 1) {
|
|
+ return 0;
|
|
+ }
|
|
+ return strcmp(name, psi.pr_fname) == 0;
|
|
+}
|
|
+#endif /* OSaix */
|
|
+
|
|
|
|
static void
|
|
do_findprocs(void)
|