tags:

views:

37

answers:

1

I am building a simple PHP daemon script, using a php Daemon class provided at:
http://www.phpclasses.org/browse/file/8958.html

I'm stuck with this class for better or worse, and I don't have much time to get this done; so in order to issue custom commands to the daemon I'm just using a command file located in the /tmp directory. However I need to delete this file after the daemon has processed any commands contained therein.

However, when I try to "unlink" the file in PHP, the unlink operation simply fails, and the file remains. I know for a fact that it is not a permissions issue. In fact I am quite certain this has something to do with the fact that each "iteration" of the daemon is spawned as a child process, and that sub-process must somehow not have permission to delete files.

My question: Why can't PHP delete this file, and what can I do about it?

+1  A: 

/tmp usually has the sticky bit set so i believe only the user which deposited the file there can delete it. Do your child processes run under the same user as the parent process (apache, www, etc..)? Which process instance created the file?

prodigitalson
I'm running the script as "php daemonscript.php" from the command line as root. I can't imagine the initial process that loads the daemon class would be able to spawn the child as anything other than root.
Brian Lacy
neither can i - but you might want to check it out.
prodigitalson
Wow, thats interesting. For testing purposes I put a sleep(15) delay at the beginning of my script. When I first run my script, then run "top" I see the "php" process, and the user is "root". After 15 seconds, a new process is spawned, and the user is now "99"!Any ideas how to fix that?
Brian Lacy
Looks liek there are variables in that class for the uid and gid to use and they default to `99`. i would try setting those appropriately.
prodigitalson