diff options
author | Wichert Akkerman <wakkerma@debian.org> | 2002-02-01 15:42:57 +0000 |
---|---|---|
committer | Wichert Akkerman <wakkerma@debian.org> | 2002-02-01 15:42:57 +0000 |
commit | b16258a118489e995f309b6e9e7f140cf11cf0dd (patch) | |
tree | 38a1d9550373c84254a1590abdbf7f7bb93be475 /utils | |
parent | 84873bd754b0720b3801342c1ca73330113fb2f8 (diff) | |
download | dpkg-b16258a118489e995f309b6e9e7f140cf11cf0dd.tar.gz |
HP-UX support for start-stop-daemon
Diffstat (limited to 'utils')
-rw-r--r-- | utils/start-stop-daemon.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c index f75ef998e..d65e071b8 100644 --- a/utils/start-stop-daemon.c +++ b/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 */ |