summaryrefslogtreecommitdiff
blob: ceb9dbf8565b4969c4b9f90511ebd5c2e1264de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff -Naur eflite-0.3.8.orig/es.c eflite-0.3.8/es.c
--- eflite-0.3.8.orig/es.c	2004-02-20 15:58:35.000000000 -0800
+++ eflite-0.3.8/es.c	2004-03-21 23:32:25.000000000 -0800
@@ -760,9 +760,13 @@
   char *input = NULL;
   int more_opts = 1;
   int debug = 0;
+  int daemon_only = 0;
 
-  while (more_opts) switch(getopt_long(argc, argv, "df:v", (struct option *)&longopts, NULL))
+  while (more_opts) switch(getopt_long(argc, argv, "Ddf:v", (struct option *)&longopts, NULL))
   {
+  case 'D':
+    daemon_only = 1;
+    break;
   case 'd':
     debug = 1;
     break;
@@ -783,19 +787,32 @@
   sockname = lookup_string(NULL, "socketfile");
   if (!sockname) sockname = "/tmp/es.socket";
   local_fd = sockconnect(sockname);
-  if (local_fd != -1) passthrough(infile, local_fd);
-  if (!debug && (child = fork()))
+
+  if(daemon_only)
   {
-    usleep(200000);
-    local_fd = sockconnect(sockname);
-    if (local_fd == -1)
+    if(local_fd != -1)
     {
-      es_log(1 | LOG_STDERR, "Daemon not accepting connections -- exiting\n");
+      es_log(1 | LOG_STDERR, "Socket already exists.  Exiting.\n");
       exit(1);
     }
-    passthrough(infile, local_fd);
-    exit(0);
   }
+  else
+  {
+    if (local_fd != -1) passthrough(infile, local_fd);
+    if (!debug && (child = fork()))
+    {
+      usleep(200000);
+      local_fd = sockconnect(sockname);
+      if (local_fd == -1)
+      {
+        es_log(1 | LOG_STDERR, "Daemon not accepting connections -- exiting\n");
+        exit(1);
+      }
+      passthrough(infile, local_fd);
+      exit(0);
+    }
+  }
+
   punct_some = lookup_string(NULL, "punct_some");
   if (punct_some == NULL) punct_some = "@#$%^&_[]{}\\|";
   punct_all = lookup_string(NULL, "punct_all");