PHP-Daemon icon indicating copy to clipboard operation
PHP-Daemon copied to clipboard

could not start daemon

Open billsion opened this issue 7 years ago • 5 comments

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

billsion avatar Sep 29 '18 09:09 billsion

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.

infusion avatar Sep 29 '18 23:09 infusion

Hi, thanks for your reply. but I still wondering how can I fixed this error.

  • [ ] I run this script as root, whoami returns 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 comment posix_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/0 and /dev/tty1

BR Bill

billsion avatar Sep 30 '18 01:09 billsion

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.

infusion avatar Sep 30 '18 06:09 infusion

Hi Sure, I got hello when I run echo "hello" > /dev/pts/0

BR Bill

billsion avatar Sep 30 '18 06:09 billsion

Have you tried to change the chmod of the device? Or maybe it's affected by the umask

infusion avatar Sep 30 '18 08:09 infusion