> Ok let be more specific about my idea. Because I'm better php programer
> than C I decided to write this in php. I use comandline php.
> 
> I want to write some daemon to be started
> 
> ./myprog &
> 
> Than this has to be run until I cancel it. But I also want to check
> somehow, what this proces is doing right now.

ps ax will tell you if it is still running or not.  If you need more info you 
can check out /proc.

> for example like in apache.
> 
> you start it with apachectl start. than you can say apachectl restart to
> reread config. And for example you could use apachectl status to output
> some info about runing server.

They coded it that way.  If ps ax and /proc are not enough info for you then 
you'll need to code whatever else you need into your script.

> This program I'll make will be run in infinite loop. It will be reading
> some file on disk and doing something with this data.
> 
> Do I have to use any usleep function. What is with CPU % when i run such
> script.

usleep sleeps, there is very little overhead in sleeping.  The cpu usage will 
be determined more by what you make it do when it's not sleeping than when it 
is.

> Is there any real examples.

Yes, I already gave you the url: http://php.net/pcntl
There's an example right there on the page.  It lets you handle hangups, 
restarts, etc.  Copy and paste that and add your own code in the while(1) loop.

> I read on devshed article about TCP socket
> listenig, but I don't like this.

That's pretty much how it's done.  If you want to listen to a program you have 
to use some type of socket, tcp is they way I'd go.


-- 
Greg Donald
http://destiney.com/



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

Reply via email to