Added PID file (thanx to Joerg)
authorAndreas Eversberg <andreas@eversberg.eu>
Sun, 15 Mar 2009 08:20:20 +0000 (09:20 +0100)
committerAndreas Eversberg <andreas@eversberg.eu>
Sun, 15 Mar 2009 08:20:20 +0000 (09:20 +0100)
modified:   README
modified:   main.c

README
main.c

diff --git a/README b/README
index 3484872..9ac4769 100644 (file)
--- a/README
+++ b/README
@@ -472,4 +472,5 @@ Changes after Version 1.3 release
 Changes after Version 1.4 release
 - Bugfix: When reloading interfaces, interface will not be reopened, if
   interface was specified by name.
+- Added PID file (thanx to Joerg)
 
diff --git a/main.c b/main.c
index 0a85f46..73cfe49 100644 (file)
--- a/main.c
+++ b/main.c
@@ -314,6 +314,7 @@ int main(int argc, char *argv[])
        if (!(strcasecmp(argv[1],"fork")))
        {
                pid_t pid;
+               FILE *pidfile;
 
                /* do daemon fork */
                pid = fork();
@@ -344,6 +345,11 @@ int main(int argc, char *argv[])
                        exit(0);
                }
                nooutput = 1;
+
+               /* write pid file */
+               pidfile = fopen("/var/run/lcr.pid","w");
+               fprintf(pidfile, "%d\n", getpid());
+               fclose(pidfile);
        } else
        /* if not start */
        if (!!strcasecmp(argv[1],"start"))