PHP-Daemon
PHP-Daemon copied to clipboard
could not start daemon
Hi,
while I run
php daemon
I have the following error:
Warning: fopen(/dev/pts/0): failed to open stream: Permission denied on line 41(./lib/main.php) -> array ( 'screen' => '/dev/pts/0',
any suggestion?
Thanks in advance BR Bill
This is a feature I liked on my daemons. When you start your daemon as root user, the daemon is detached from the current terminal and runs in the background. All output are thrown away and the process runs under an unprivileged user. To get the output back to your current terminal, you can send a USR signal to the process. For me it was /dev/pts/** on Linux. Possible problems are:
- you did not start the process as root
- you run in a VM where accessing the pts device is not allowed
- The path is not correct with a misleading messag
If you don't need the feature, comment out the console opening.
Hi, thanks for your reply. but I still wondering how can I fixed this error.
- [ ] I run this script as root,
whoamireturns root. - [ ] Yes, this scripts stores in VirtualBox, actually even I run this script in the real terminal, same error still there, it says:
Warning: fopen(/dev/pts/tty1): failed to open stream: Permission denied on line 41(./lib/main.php) -> array ( 'screen' => '/dev/pts/tty1',. and I found that once I commentposix_setuid(DAEMON_UID), the error gone. - [ ] I'm sure the path is correct, because one I comment the
posix_setuid(DAEMON_UID), no error occur. and I can open both/dev/pts/0and/dev/tty1
BR Bill
Do you get an output when you run:
echo "hello" > /dev/pts/0
The last point sounds like you are not allowed to access the device after the daemon changed its user. If this is the case, I would skip this feature entirely by commenting it out.
Hi
Sure, I got hello when I run
echo "hello" > /dev/pts/0
BR Bill
Have you tried to change the chmod of the device? Or maybe it's affected by the umask