User(s) browsing this thread: 1 Guest(s)
unix/c gurus - Starting a process from gaya without it hanging
|
|
05-01-2010, 06:27 PM
(This post was last modified: 05-01-2010 07:00 PM by lordy.)
|
|||
|
|||
|
unix/c gurus - Starting a process from gaya without it hanging
Hi,
I have a few cgi applications where I want to start a long running process. However on nmt100 this causes Gaya to hang. So I thought I'd write a daemon launcher, but still gaya waits for it to finish. Can anyone see what the problem is... (note that gaya is invoking the daemon process directly and not going via wget/sybhttpd) References : here and here The following program should allow gaya to launch any command as Code: daemon command argsbut gaya still waits for termination. Maybe it is a signalling issue ? (ignore the php tag )PHP Code: #include <sys/types.h>Oversight: Jukebox | FeedTime: Automatic nzbs |
|||
|
05-01-2010, 07:35 PM
|
|||
|
|||
|
RE: unix/c gurus - Starting a process from gaya without it hanging
Hi,
I sussed it. The first of the three processes should call exit() to signal back to gaya to move on The others should use _exit().If anyone is interested the daemon launcher will be a small executable bundled with the next version of oversight. They are welcome to use it, to stop gaya waiting for long running processes. It also means I can remove the cron job hack. Oversight: Jukebox | FeedTime: Automatic nzbs |
|||
|
05-01-2010, 07:38 PM
|
|||
|
|||
|
RE: unix/c gurus - Starting a process from gaya without it hanging
It might be better for your application to just run in the background on startup and then signal it to do something instead of launch it to run.
|
|||
|
05-01-2010, 07:55 PM
(This post was last modified: 05-01-2010 07:56 PM by lordy.)
|
|||
|
|||
|
RE: unix/c gurus - Starting a process from gaya without it hanging
Hi, accident, thanks for the suggestion, I try to minimise the number of long running processes on the NMT.
I do have regular scans that are started by a cron job. , but I just need this for when the user initiates a manual scan. (which hopefully is not often). Now I have this working, it means oversight does not add any overhead to NMT resources. Overall its easier now to just say.. Code: daemon command argsrather than develop an additional server, and manage its installation/startup/shutdown to avoid this issue. I did have a horrible hack in place before this to launch user scans, back when Oversight was just bash/awk scripts. I had a cron job that check for new commands every minute. I didn't have the toolchain in place at the time to write proper code! It actually worked better than expected but now I can get rid of it! However, somewhere down the line, for top performance , I may need to introduce a proper server process for performance reasons. At the moment oversight scans the entire video inventory during every page load. (400 items in about 10ms on c200. 250 items in 30ms on hdx1000 ) but performance will degrade with bigger collections, so a full client/server architecture *may* help here. Oversight: Jukebox | FeedTime: Automatic nzbs |
|||
|
05-02-2010, 03:43 AM
|
|||
|
|||
|
RE: unix/c gurus - Starting a process from gaya without it hanging
Look about right, you fork(), child->setsid() close(0,1,2) and execve a new process.
Your double fork should not be required (any more, legacy) |
|||
|
05-04-2010, 06:43 PM
|
|||
|
|||
|
RE: unix/c gurus - Starting a process from gaya without it hanging
Tx, gaya was waiting for one of the sub-processes to call exit() ( rather than _exit() ).
Interesting about the double fork - I'll go do some reading... Oversight: Jukebox | FeedTime: Automatic nzbs |
|||
|
« Next Oldest | Next Newest »
|

Twitter
Facebook
NMT Wiki
Search
Member List
Help
[19. June 2013] Soundcloud® available now

unix/c gurus - Starting a process from gaya without it hanging


)
![[+]](images/collapse_collapsed.gif)



