Motion - Support Question 2008x 12x 11x 134201

Running motion on a Nokia N810

Question

Hi -

I've compiled motion for a Nokia N810 tablet, and it runs fine in non-daemon mode. But in daemon mode, it starts up successfully, but dies. Not quite sure where to start debugging this... ideas?

[0] Processing thread 0 - config file /home/user/camera/motion.conf
[0] Motion 3.2.11 Started
[0] Motion going to daemon mode 

Environment

Motion version: 3.2.11
ffmpeg version:  
Libraries:  
Server OS: Nokia N810, kernel 2.6.21

-- JonathanMiner - 11 Dec 2008

Follow Up

Could be a good idea to upload your config file ... but as a quick guess

1-. Check process_id_file value ( probably motion has not permission to create file)

2-. Check rights of value for target_dir

ummm also log files ... not sure where are stored on that gadget , motion uses syslog.

-- AngelCarpintero - 12 Dec 2008

Update

When I originally posed the question, the process_id_file was "./motion.pid" and target_dir was commented out. I've since changed them to be:
daemon on 
process_id_file "/home/user/camera/motion.pid"
target_dir /home/user/camera

Logging is challenging... "dmesg" doesn't show any "motion" related stuff, and there is no syslog daemon. I did notice this morning, that when running in daemon mode, the pid file does not get updated. In non-daemon mode (motion -n) it does get updated. Additionally, I made a small change to the motion.c file to examine the behavior of fork():
--- motion.c.dist    2008-09-21 19:20:58.000000000 -0400
+++ motion.c    2008-12-15 10:57:05.000000000 -0500
@@ -1935,6 +1935,7 @@
 static void become_daemon(void)
 {
     int i;
+    pid_t pid;
     FILE *pidf = NULL;    
     struct sigaction sig_ign_action;
 
@@ -1948,7 +1949,13 @@
     sigemptyset(&sig_ign_action.sa_mask);
 
     /* fork */
-    if (fork()) {
+    pid = fork();
+    
+    if (pid == -1) {
+        motion_log(-1, 0, "Motion failed to go into daemon mode");
+        exit(0);
+    }
+    else if (pid == 0) {
         motion_log(-1, 0, "Motion going to daemon mode");
         exit(0);
     }
@@ -1962,7 +1969,7 @@
         pidf = fopen(cnt_list[0]->conf.pid_file, "w+");
     
         if (pidf ) {
-            (void)fprintf(pidf, "%d\n", getpid());
+            (void)fprintf(pidf, "%d\n", pid);
             fclose(pidf);
         } else {
             motion_log(LOG_ERR, 1, "Exit motion, cannot create process id file (pid file) %s",
@@ -1978,7 +1985,7 @@
     }
 
 #if (defined(BSD))
-    setpgrp(0, getpid());
+    setpgrp(0, pid);
 #else
     setpgrp();
 #endif /* BSD */ 

After patching, and modifing the config file, the behavior has changed slightly:

When running "./motion -n", lots of screen output as expected

When running "./motion", goes into daemon mode, but control not returned to the shell.

When running "./motion &", goes into daemon mode, and control returned to the shell.

-- JonathanMiner - 15 Dec 2008

Answer

Nokia N810 runs Maemo OS ( based in linux ) but probably exec() , fork() and probably other libc fuctions could have a different behaviour.

Best way to fix this is to get the SDK/Documentation of porting linux app to Maemo.

-- AngelCarpintero - 16 Nov 2009
Topic revision: r6 - 21 Mar 2010, AngelCarpintero
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.