Przeglądaj źródła

HP-UX support for start-stop-daemon

Wichert Akkerman 24 lat temu
rodzic
commit
b16258a118
3 zmienionych plików z 70 dodań i 2 usunięć
  1. 5 0
      ChangeLog
  2. 1 0
      debian/changelog
  3. 64 2
      utils/start-stop-daemon.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Fri Feb  1 16:41:23 CET 2002 Wichert Akkerman <wakkerma@debian.org>
+
+  * utils/start-stop-daemon.c: Merge patch from Andres Voegele
+    <voegelas@users.sourceforge.net> to add HP-UX support
+    
 Fri Feb  1 13:58:59 CET 2002 Wichert Akkerman <wakkerma@debian.org>
 
   * po/fr.po: updated.

+ 1 - 0
debian/changelog

@@ -74,6 +74,7 @@ dpkg (1.10) unstable; urgency=low
   * update-alternative exits with a non-zero exit code when displaying
     a non-existing alternative. Closes: Bug#131496
   * Use gzip -c in install-info. Closes: Bug#131758
+  * start-stop-daemon works on HP-UX now. Closes: Bug#130130
 
  -- Wichert Akkerman <wakkerma@debian.org>  Mon, 20 Aug 2001 14:54:38 +0200
 

+ 64 - 2
utils/start-stop-daemon.c

@@ -30,6 +30,8 @@
 #  define OSsunos
 #elif defined(OPENBSD)
 #  define OSOpenBSD
+#elif defined(hpux)
+#  define OShpux
 #else
 #  error Unknown architecture - cannot build start-stop-daemon
 #endif
@@ -54,6 +56,11 @@
 #include <limits.h>
 #endif
 
+#if defined(OShpux)
+#include <sys/param.h>
+#include <sys/pstat.h>
+#endif
+
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -140,7 +147,7 @@ static void check(pid_t pid);
 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)
+#if defined(OSLinux) || defined(OShpux)
 static int pid_is_exec(pid_t pid, const struct stat *esb);
 #endif
 
@@ -666,7 +673,7 @@ pid_is_running(pid_t pid)
 static void
 check(pid_t pid)
 {
-#if defined(OSLinux)
+#if defined(OSLinux) || defined(OShpux)
 	if (execname && !pid_is_exec(pid, &exec_stat))
 #elif defined(OSHURD)
     /* I will try this to see if it works */
@@ -855,6 +862,54 @@ do_procinit(void)
 #endif /* OSOpenBSD */
 
 
+#if defined(OShpux)
+static int
+pid_is_user(pid_t pid, uid_t uid)
+{
+	struct pst_status pst;
+
+	if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0)
+		return 0;
+	return ((uid_t) pst.pst_uid == uid);
+}
+
+static int
+pid_is_cmd(pid_t pid, const char *name)
+{
+	struct pst_status pst;
+
+	if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0)
+		return 0;
+	return (strcmp(pst.pst_ucomm, name) == 0);
+}
+
+static int
+pid_is_exec(pid_t pid, const struct stat *esb)
+{
+	struct pst_status pst;
+
+	if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0)
+		return 0;
+	return ((dev_t) pst.pst_text.psf_fsid.psfs_id == esb->st_dev
+		&& (ino_t) pst.pst_text.psf_fileid == esb->st_ino);
+}
+
+static void
+do_procinit(void)
+{
+	struct pst_status pst[10];
+	int i, count;
+	int idx = 0;
+
+	while ((count = pstat_getproc(pst, sizeof(pst[0]), 10, idx)) > 0) {
+                for (i = 0; i < count; i++)
+			check(pst[i].pst_pid);
+                idx = pst[count - 1].pst_idx + 1;
+	}
+}
+#endif /* OShpux */
+
+
 static void
 do_findprocs(void)
 {
@@ -1154,12 +1209,19 @@ main(int argc, char **argv)
 			exit(0);
 		}
 		 /* child continues here */
+#if defined(OShpux)
+		/* create a new session */
+		setsid();
+		 /* now close all extra fds */
+		for (i=sysconf(_SC_OPEN_MAX)-1; i>=0; --i) close(i);
+#else
 		 /* now close all extra fds */
 		for (i=getdtablesize()-1; i>=0; --i) close(i);
 		 /* change tty */
 		fd = open("/dev/tty", O_RDWR);
 		ioctl(fd, TIOCNOTTY, 0);
 		close(fd);
+#endif
 		chdir("/");
 		umask(022); /* set a default for dumb programs */
 		setpgid(0,0);  /* set the process group */