Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin Use pidfile(3).



details:   https://anonhg.NetBSD.org/src/rev/a3c0258b3078
branches:  trunk
changeset: 473502:a3c0258b3078
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jun 06 01:50:23 1999 +0000

description:
Use pidfile(3).

diffstat:

 usr.sbin/inetd/Makefile      |   6 +++---
 usr.sbin/inetd/inetd.c       |  20 ++++----------------
 usr.sbin/inetd/pathnames.h   |   3 +--
 usr.sbin/mountd/mountd.c     |  11 +++--------
 usr.sbin/mountd/pathnames.h  |   3 +--
 usr.sbin/syslogd/pathnames.h |   3 +--
 usr.sbin/syslogd/syslogd.c   |  13 +++----------
 7 files changed, 16 insertions(+), 43 deletions(-)

diffs (216 lines):

diff -r db7c58328035 -r a3c0258b3078 usr.sbin/inetd/Makefile
--- a/usr.sbin/inetd/Makefile   Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/inetd/Makefile   Sun Jun 06 01:50:23 1999 +0000
@@ -1,5 +1,5 @@
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
-#      $NetBSD: Makefile,v 1.14 1997/10/25 06:58:06 lukem Exp $
+#      $NetBSD: Makefile,v 1.15 1999/06/06 01:53:45 thorpej Exp $
 
 PROG=  inetd
 MAN=   inetd.8
@@ -8,7 +8,7 @@
 CPPFLAGS+=-DLIBWRAP
 # Use LIBWRAP_INTERNAL for libwrap checking of inetd's `internal' services.
 #CPPFLAGS+=-DLIBWRAP_INTERNAL
-LDADD+= -lwrap
-DPADD+= ${LIBWRAP}
+LDADD+= -lwrap -lutil
+DPADD+= ${LIBWRAP} ${LIBUTIL}
 
 .include <bsd.prog.mk>
diff -r db7c58328035 -r a3c0258b3078 usr.sbin/inetd/inetd.c
--- a/usr.sbin/inetd/inetd.c    Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/inetd/inetd.c    Sun Jun 06 01:50:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inetd.c,v 1.47 1999/04/11 15:40:58 hwr Exp $   */
+/*     $NetBSD: inetd.c,v 1.48 1999/06/06 01:53:45 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
 #if 0
 static char sccsid[] = "@(#)inetd.c    8.4 (Berkeley) 4/13/94";
 #else
-__RCSID("$NetBSD: inetd.c,v 1.47 1999/04/11 15:40:58 hwr Exp $");
+__RCSID("$NetBSD: inetd.c,v 1.48 1999/06/06 01:53:45 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -221,6 +221,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
+#include <util.h>
 
 #include "pathnames.h"
 
@@ -349,7 +350,6 @@
 char          *skip __P((char **));
 void           tcpmux __P((int, struct servtab *));
 void           usage __P((void));
-void           logpid __P((void));
 void           register_rpc __P((struct servtab *sep));
 void           unregister_rpc __P((struct servtab *sep));
 void           bump_nofile __P((void));
@@ -466,7 +466,7 @@
        if (debug == 0)
                daemon(0, 0);
        openlog(__progname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
-       logpid();
+       pidfile(NULL);
 
 #ifdef RLIMIT_NOFILE
        if (getrlimit(RLIMIT_NOFILE, &rlim_ofile) < 0) {
@@ -995,7 +995,6 @@
                }
                (void)close(sep->se_fd);
        }
-       (void)unlink(_PATH_INETDPID);
        exit(0);
 }
 
@@ -1640,17 +1639,6 @@
 }
 
 void
-logpid()
-{
-       FILE *fp;
-
-       if ((fp = fopen(_PATH_INETDPID, "w")) != NULL) {
-               fprintf(fp, "%u\n", getpid());
-               (void)fclose(fp);
-       }
-}
-
-void
 bump_nofile()
 {
 #ifdef RLIMIT_NOFILE
diff -r db7c58328035 -r a3c0258b3078 usr.sbin/inetd/pathnames.h
--- a/usr.sbin/inetd/pathnames.h        Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/inetd/pathnames.h        Sun Jun 06 01:50:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pathnames.h,v 1.5 1997/10/05 16:16:15 mrg Exp $        */
+/*     $NetBSD: pathnames.h,v 1.6 1999/06/06 01:53:45 thorpej Exp $    */
 
 /*
  * Copyright (c) 1989 The Regents of the University of California.
@@ -38,4 +38,3 @@
 #include <paths.h>
 
 #define        _PATH_INETDCONF "/etc/inetd.conf"
-#define _PATH_INETDPID "/var/run/inetd.pid"
diff -r db7c58328035 -r a3c0258b3078 usr.sbin/mountd/mountd.c
--- a/usr.sbin/mountd/mountd.c  Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/mountd/mountd.c  Sun Jun 06 01:50:23 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mountd.c,v 1.52 1999/01/12 15:11:53 christos Exp $  */
+/* $NetBSD: mountd.c,v 1.53 1999/06/06 01:50:23 thorpej Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -51,7 +51,7 @@
 #if 0
 static char     sccsid[] = "@(#)mountd.c  8.15 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: mountd.c,v 1.52 1999/01/12 15:11:53 christos Exp $");
+__RCSID("$NetBSD: mountd.c,v 1.53 1999/06/06 01:50:23 thorpej Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -269,7 +269,6 @@
        char **argv;
 {
        SVCXPRT *udptransp, *tcptransp;
-       FILE *pidfile;
        int c;
 
        while ((c = getopt(argc, argv, "dnr")) != -1)
@@ -310,11 +309,7 @@
        }
        (void)signal(SIGHUP, get_exportlist);
        (void)signal(SIGTERM, send_umntall);
-       pidfile = fopen(_PATH_MOUNTDPID, "w");
-       if (pidfile != NULL) {
-               (void)fprintf(pidfile, "%d\n", getpid());
-               (void)fclose(pidfile);
-       }
+       pidfile(NULL);
        if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL ||
            (tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) {
                syslog(LOG_ERR, "Can't create socket");
diff -r db7c58328035 -r a3c0258b3078 usr.sbin/mountd/pathnames.h
--- a/usr.sbin/mountd/pathnames.h       Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/mountd/pathnames.h       Sun Jun 06 01:50:23 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pathnames.h,v 1.6 1995/03/18 14:58:35 cgd Exp $        */
+/*     $NetBSD: pathnames.h,v 1.7 1999/06/06 01:50:23 thorpej Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,4 +39,3 @@
 
 #define        _PATH_EXPORTS           "/etc/exports"
 #define        _PATH_RMOUNTLIST        "/var/db/mountdtab"
-#define _PATH_MOUNTDPID                "/var/run/mountd.pid"
diff -r db7c58328035 -r a3c0258b3078 usr.sbin/syslogd/pathnames.h
--- a/usr.sbin/syslogd/pathnames.h      Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/syslogd/pathnames.h      Sun Jun 06 01:50:23 1999 +0000
@@ -31,11 +31,10 @@
  * SUCH DAMAGE.
  *
  *     from: @(#)pathnames.h   8.1 (Berkeley) 6/6/93
- *     $NetBSD: pathnames.h,v 1.3 1996/01/02 17:30:29 perry Exp $
+ *     $NetBSD: pathnames.h,v 1.4 1999/06/06 01:55:58 thorpej Exp $
  */
 
 #include <paths.h>
 
 #define        _PATH_KLOG      "/dev/klog"
 #define        _PATH_LOGCONF   "/etc/syslog.conf"
-#define        _PATH_LOGPID    "/var/run/syslog.pid"
diff -r db7c58328035 -r a3c0258b3078 usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c        Sun Jun 06 01:50:00 1999 +0000
+++ b/usr.sbin/syslogd/syslogd.c        Sun Jun 06 01:50:23 1999 +0000
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)syslogd.c  8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.26 1999/02/28 11:46:26 tron Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.27 1999/06/06 01:55:58 thorpej Exp $");
 #endif
 #endif /* not lint */
 
@@ -108,7 +108,6 @@
 #include <sys/syslog.h>
 
 char   *ConfFile = _PATH_LOGCONF;
-char   *PidFile = _PATH_LOGPID;
 char   ctty[] = _PATH_CONSOLE;
 
 #define FDMASK(fd)     (1 << (fd))
@@ -224,7 +223,6 @@
        int funixsize = 0, funixmaxsize = 0;
        struct sockaddr_un sunx, fromunix;
        struct sockaddr_in sin, frominet;
-       FILE *fp;
        char *p, *line, **pp;
        struct pollfd *readfds;
 
@@ -349,13 +347,8 @@
        }
 
        /* tuck my process id away, if i'm not in debug mode */
-       if (Debug == 0) {
-               fp = fopen(PidFile, "w");
-               if (fp != NULL) {
-                       fprintf(fp, "%d\n", getpid());
-                       (void) fclose(fp);
-               }
-       }
+       if (Debug == 0)
+               pidfile(NULL);
 
        dprintf("off & running....\n");
 



Home | Main Index | Thread Index | Old Index