Enlightenment CVS committal

Author  : gilbertt
Project : misc
Module  : camE

Dir     : misc/camE


Modified Files:
        webcam.c 


Log Message:

Patch from Nick Estes <[EMAIL PROTECTED]> to support daemonising.


===================================================================
RCS file: /cvsroot/enlightenment/misc/camE/webcam.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -3 -r1.67 -r1.68
--- webcam.c    1 Oct 2003 10:30:25 -0000       1.67
+++ webcam.c    10 Oct 2003 12:58:48 -0000      1.68
@@ -37,7 +37,7 @@
 #include "parseconfig.h"
 #include "pwc-ioctl.h"
 
-#define VERSION "1.6"
+#define VERSION "1.7"
 
 void log(char *fmt,
          ...);
@@ -1107,6 +1107,7 @@
   printf("usage: camE [OPTION]\n");
   printf("       -c FILE    Use config file FILE\n");
   printf("       -f         Don't fork to background\n");
+  printf("       -d         Detach after forking\n");
   printf("       -s         Single shot\n");
   printf("       -h -v      This message\n");
   exit(0);
@@ -1190,15 +1191,28 @@
   int single_shot = 0;
   int offline_done = 1;
   char *config_file = NULL;
+  int detach = 0;
+  int ret;
 
-  while ((ch = getopt(argc, argv, "c:fshv")) != EOF) {
+  while ((ch = getopt(argc, argv, "c:fsdhv")) != EOF) {
     switch (ch) {
       case 'c':
         config_file = strdup(optarg);
         break;
       case 'f':
+        if (detach) {
+          fprintf(stderr, "-f does not make sense with -d specified.\n");
+          exit(1);
+        }
         dont_fork = 1;
         break;
+      case 'd':
+        if (dont_fork) {
+          fprintf(stderr, "-d does not make sense with -f specified.\n");
+          exit(1);
+        }
+        detach = 1;
+        break;
       case 's':
         single_shot = 1;
         break;
@@ -1217,7 +1231,11 @@
 
   if (!dont_fork && !single_shot) {
     /* fork and die */
-    if ((childpid = fork()) < 0) {
+    if (detach) {
+      ret = daemon(1,0);
+      if (ret != 0)
+       fprintf(stderr, "daemon (%s)\n", strerror(errno));
+    } else if ((childpid = fork()) < 0) {
       fprintf(stderr, "fork (%s)\n", strerror(errno));
       return (2);
     } else if (childpid > 0)




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to