aboutsummaryrefslogtreecommitdiffstats
path: root/lcd4linux.c
diff options
context:
space:
mode:
authorreinelt <>2003-08-08 08:05:23 +0000
committerreinelt <>2003-08-08 08:05:23 +0000
commit2cce4542730411c90986f180bb0dc43af87278be (patch)
treed9085aee0f8ec93f5b6db97f93e501fc953e793a /lcd4linux.c
parentc5e120b8fe161ad249c4c5b39882d7129cd38761 (diff)
downloadlcd4linux-2cce4542730411c90986f180bb0dc43af87278be.tar.gz
[lcd4linux @ 2003-08-08 08:05:23 by reinelt]
added PID file handling
Diffstat (limited to 'lcd4linux.c')
-rw-r--r--lcd4linux.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/lcd4linux.c b/lcd4linux.c
index 9a1e64b..6a357f7 100644
--- a/lcd4linux.c
+++ b/lcd4linux.c
@@ -1,4 +1,4 @@
-/* $Id: lcd4linux.c,v 1.40 2003/08/08 06:58:06 reinelt Exp $
+/* $Id: lcd4linux.c,v 1.41 2003/08/08 08:05:23 reinelt Exp $
*
* LCD4Linux
*
@@ -20,6 +20,9 @@
*
*
* $Log: lcd4linux.c,v $
+ * Revision 1.41 2003/08/08 08:05:23 reinelt
+ * added PID file handling
+ *
* Revision 1.40 2003/08/08 06:58:06 reinelt
* improved forking
*
@@ -217,10 +220,13 @@
#include "cfg.h"
#include "debug.h"
+#include "pid.h"
#include "udelay.h"
#include "display.h"
#include "processor.h"
+#define PIDFILE "/var/run/lcd4linux.pid"
+
char *release="LCD4Linux " VERSION " (c) 2003 Michael Reinelt <reinelt@eunet.at>";
char **my_argv;
char *output=NULL;
@@ -428,6 +434,14 @@ int main (int argc, char *argv[])
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
close(fd);
+
+ // create PID file
+ if (pid_init(PIDFILE)!=0) {
+ error ("PID file creation failed!");
+ exit (1);
+ }
+
+ // now we are a daemon
background=1;
}
@@ -469,6 +483,8 @@ int main (int argc, char *argv[])
if (!quiet) hello();
lcd_quit();
+ pid_exit(PIDFILE);
+
if (got_signal==SIGHUP) {
long fd;
debug ("restarting...");