summaryrefslogtreecommitdiff
path: root/usr.sbin/screenblank/screenblank.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/screenblank/screenblank.c')
-rw-r--r--usr.sbin/screenblank/screenblank.c19
1 files changed, 16 insertions, 3 deletions
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()
{