diff -Naur ucarp-1.2/src/carp.c ucarp-1.2-pa/src/carp.c
--- ucarp-1.2/src/carp.c	2006-02-18 23:06:17.000000000 +0000
+++ ucarp-1.2-pa/src/carp.c	2007-08-24 12:43:59.000000000 +0000
@@ -609,9 +609,10 @@
     logfile(LOG_DEBUG, "sighandler_exit(): Calling [%s] and exiting",
             downscript);
 #endif
-    if (sc.sc_state != BACKUP) {
+    if (sc.sc_state != BACKUP && shutdown_at_exit != 0) {
 	(void) spawn_handler(dev_desc_fd, downscript);
     }
+    unlink("/var/run/ucarp.pid");
     _exit(EXIT_SUCCESS);
 }
 
@@ -691,11 +692,11 @@
     pfds[0].fd = dev_desc_fd;
     pfds[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
     
-    if (shutdown_at_exit != 0) {
-        (void) signal(SIGINT, sighandler_exit);
-        (void) signal(SIGQUIT, sighandler_exit);
-        (void) signal(SIGTERM, sighandler_exit);
-    }
+    // if (shutdown_at_exit != 0) {
+    (void) signal(SIGINT, sighandler_exit);
+    (void) signal(SIGQUIT, sighandler_exit);
+    (void) signal(SIGTERM, sighandler_exit);
+    // }
 
     if (gettimeofday(&now, NULL) != 0) {
 	logfile(LOG_WARNING, "initializing now to gettimeofday() failed: %s",
diff -Naur ucarp-1.2/src/daemonize.c ucarp-1.2-pa/src/daemonize.c
--- ucarp-1.2/src/daemonize.c	2004-08-28 15:15:21.000000000 +0000
+++ ucarp-1.2-pa/src/daemonize.c	2007-08-24 12:33:28.000000000 +0000
@@ -42,6 +42,18 @@
     return 0;
 }
 
+static void write_pidfile(void)
+{
+    FILE *file;
+    
+    if(! (file = fopen("/var/run/ucarp.pid", "w"))) {
+        logfile(LOG_ERR, _("Unable to write pid file: [fork: %s]"),
+          strerror(errno));
+    }
+    fprintf(file, "%d\n", getpid());
+    fclose(file);
+}
+
 void dodaemonize(void)
 { 
     pid_t child;
@@ -74,6 +86,7 @@
                     _("Unable to detach: /dev/null can't be duplicated"));
             _exit(EXIT_FAILURE);
         }
+        write_pidfile();
     }
 }
 

