Re: Start/stop daemon using php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Per Jessen skrev:
David Sveningsson wrote:

Hi, I've written an application in c which I would like to start/stop
as a daemon in gnu/linux.

The application has the argument "--daemon" which forks the process
and exits the parent. Then it setups a SIGQUIT signal handler to
properly cleanup and terminate. It also maintains a lockfile (with the
pid) so only one instance is allowed.

So, to start this application I created a php site that calls
exec("/path/to/binary --daemon > /dev/null 2> /dev/null").

Everything is working so far, but I cannot get the application to
receive the SIGQUIT when I start using php and exec. Not even manually
using kill in the shell. It works correctly if I start manually
thought.

So obviously something is catching the SIGQUIT before it gets to your
daemon. You mention "a php site", so I take it you're running apache. In an apache process you then do an exec(something). I think apache is
probably taking care of the SIGQUIT.

Yes, I am using apache (forgot to mention it). Is there a way to stop apache from catching the signals?


So, is this possible to do? Doesn't exec allow applications with
signal handlers? Is there some other way to terminate the application?

Why do you have to kill it with an explicit signal - why not not have a
way of communicating with the process that'll make it terminate when
you raise a flag or send it a message or something.

Currently I have no other way of communicating than a mysql database (it passes data that needs processing) so I thought it would be quick and easy to just raise a signal. I read in another mail about D-BUS which I think would be a better way of communication.



/Per Jessen, Zürich



--


//*David Sveningsson [eXt]*

Freelance coder | Game Development Student
http://sidvind.com

Thou shalt make thy program's purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux