commit 0c252ad6a42b32fe82f39be340edd5a00abfe7d0
Author: Christophe Fergeau <[email protected]>
Date:   Tue Nov 17 00:06:27 2009 +0100

    call daemon() before grabbing SysInfoExtended
    
    We want the generation of SysInfoExtended to be asynchronous
    so as not to block event processing by udev.

 tools/test-afc.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/tools/test-afc.c b/tools/test-afc.c
index 51b60ce..09360cc 100644
--- a/tools/test-afc.c
+++ b/tools/test-afc.c
@@ -1,4 +1,8 @@
+#define _BSD_SOURCE 1 /* for daemon() */
 #include <glib.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
 
 extern char *read_sysinfo_extended_by_uuid (const char *uuid);
 extern gboolean iphone_write_sysinfo_extended (const char *uuid, const char 
*xml);
@@ -26,11 +30,24 @@ static gboolean write_sysinfo_extended (const char *uuid)
 
 int main (int argc, char **argv)
 {
+    int daemonize_failed;
+
     if (argc != 2) {
         g_print ("Usage: %s <uuid>\n", argv[0]);
         return 1;
     }
 
+    /* we don't want to block the calling process since it would delay udev
+     * event handling, and usbmuxd might not be ready yet so we could be
+     * blocking for some time. Just daemonize to run in the background, 
+     * SysInfoExtended generation can be async anyway
+     */
+    daemonize_failed = daemon (0, 0);
+    if (daemonize_failed) {
+        g_print ("%s: daemon() failed: %s\n", argv[0], strerror (errno));
+        return 1;
+    }
+
     return write_sysinfo_extended (argv[1]);
 }
 

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to