summaryrefslogtreecommitdiff
path: root/usr.sbin/screenblank/screenblank.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2001-12-01 23:27:25 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2001-12-01 23:27:25 +0000
commitb11bbb51235bd85172226ea037257b53ee9402da (patch)
treef6118a5419bc82550325ed0df2f3e50047f6ffbb /usr.sbin/screenblank/screenblank.c
parentea7f37b365f29a8552fe175609d79d58051b87c4 (diff)
Use pidfile() instead of doing the equivalent thing by hand, and sometimes
forgetting to unlink the pid file at exit. ok millert@ deraadt@
Diffstat (limited to 'usr.sbin/screenblank/screenblank.c')
-rw-r--r--usr.sbin/screenblank/screenblank.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/usr.sbin/screenblank/screenblank.c b/usr.sbin/screenblank/screenblank.c
index 41247201a32..697b2d5fa75 100644
--- a/usr.sbin/screenblank/screenblank.c
+++ b/usr.sbin/screenblank/screenblank.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screenblank.c,v 1.8 2001/11/17 00:02:34 deraadt Exp $ */
+/* $OpenBSD: screenblank.c,v 1.9 2001/12/01 23:27:24 miod Exp $ */
/* $NetBSD: screenblank.c,v 1.2 1996/02/28 01:18:34 thorpej Exp $ */
/*-
@@ -77,7 +77,6 @@ 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));
@@ -169,7 +168,7 @@ main(argc, argv)
/* Detach. */
if (daemon(0, 0))
err(1, "daemon");
- logpid();
+ pidfile(NULL);
/* Start the state machine. */
for (;;) {
@@ -247,8 +246,7 @@ sighandler(sig)
int sig;
{
- /* Kill the pid file and re-enable the framebuffer before exit. */
- (void)unlink(_PATH_SCREENBLANKPID);
+ /* Re-enable the framebuffer before exit. */
change_state(FBVIDEO_ON, 1);
_exit(0);
}
@@ -313,17 +311,6 @@ 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()
{