diff options
-rw-r--r-- | usr.sbin/screenblank/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/screenblank/pathnames.h | 3 | ||||
-rw-r--r-- | usr.sbin/screenblank/screenblank.c | 19 |
3 files changed, 21 insertions, 7 deletions
diff --git a/usr.sbin/screenblank/Makefile b/usr.sbin/screenblank/Makefile index 0b6d3ae072d..b13c5a3e1b4 100644 --- a/usr.sbin/screenblank/Makefile +++ b/usr.sbin/screenblank/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.4 2001/12/01 23:27:24 miod Exp $ +# $OpenBSD: Makefile,v 1.5 2001/12/01 23:43:48 miod Exp $ .if ${MACHINE} == "sparc" || ${MACHINE} == "sun3" PROG= screenblank -LDADD+= -lm -lutil -DPADD+= ${LIBM} ${LIBUTIL} +DPADD= ${LIBM} +LDADD= -lm .else NOPROG=yes .endif diff --git a/usr.sbin/screenblank/pathnames.h b/usr.sbin/screenblank/pathnames.h index 2828cf15be5..3ff6bdc1e24 100644 --- a/usr.sbin/screenblank/pathnames.h +++ b/usr.sbin/screenblank/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.3 2001/12/01 23:27:24 miod Exp $ */ +/* $OpenBSD: pathnames.h,v 1.4 2001/12/01 23:43:48 miod Exp $ */ /* $NetBSD: pathnames.h,v 1.2 1996/02/28 01:18:30 thorpej Exp $ */ /*- @@ -37,6 +37,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#define _PATH_SCREENBLANKPID "/var/run/screenblank.pid" #define _PATH_KEYBOARD "/dev/kbd" #define _PATH_MOUSE "/dev/mouse" #define _PATH_FB "/dev/fb" diff --git a/usr.sbin/screenblank/screenblank.c b/usr.sbin/screenblank/screenblank.c index 697b2d5fa75..9a2275ab9b5 100644 --- a/usr.sbin/screenblank/screenblank.c +++ b/usr.sbin/screenblank/screenblank.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screenblank.c,v 1.9 2001/12/01 23:27:24 miod Exp $ */ +/* $OpenBSD: screenblank.c,v 1.10 2001/12/01 23:43:48 miod Exp $ */ /* $NetBSD: screenblank.c,v 1.2 1996/02/28 01:18:34 thorpej Exp $ */ /*- @@ -77,6 +77,7 @@ extern char *__progname; static void add_dev __P((char *, int)); static void change_state __P((int, int)); static void cvt_arg __P((char *, struct timeval *)); +static void logpid __P((void)); static void sighandler __P((int)); static void usage __P((void)); @@ -168,7 +169,7 @@ main(argc, argv) /* Detach. */ if (daemon(0, 0)) err(1, "daemon"); - pidfile(NULL); + logpid(); /* Start the state machine. */ for (;;) { @@ -246,7 +247,8 @@ sighandler(sig) int sig; { - /* Re-enable the framebuffer before exit. */ + /* Kill the pid file and re-enable the framebuffer before exit. */ + (void)unlink(_PATH_SCREENBLANKPID); change_state(FBVIDEO_ON, 1); _exit(0); } @@ -311,6 +313,17 @@ cvt_arg(arg, tvp) } static void +logpid() +{ + FILE *fp; + + if ((fp = fopen(_PATH_SCREENBLANKPID, "w")) != NULL) { + fprintf(fp, "%u\n", getpid()); + (void)fclose(fp); + } +} + +static void usage() { |