Process (mplayer) doesn't read from named pipe when started from webserver (lighttpd)
1
vote
1
answer
299
views
# tl;dr
$ sudo -u www-data mplayer -slave -input file=/srv/mplayer.fifo -playlist /srv/list &
$ lsof /srv/mplayer.fifo | tail +2
mplayer 21059 www-data 4u FIFO 179,2 0t0 2359331 /srv/mplayer.fifo
$ cat /var/www/html/test
#!/usr/bin/bash
mplayer -slave -input file=/srv/mplayer.fifo -playlist /srv/list &
$ curl 'http://localhost/test' # mplayer starts playback (and keeps playing)
$ lsof /srv/mplayer.fifo
# no output!?
# details
On my **Raspberry Pi**, I have a *lighttpd* server running. It's supposed to start and control an *mplayer* process. The webserver starts mplayer with
-slave -input file=/srv/mplayer.fifo
. (So mplayer reads and executes commands from that file.) In order to skip to the next song, one of the webserver scripts writes pt_skip 1
to /srv/mplayer.fifo
. This indeed works when mplayer was run from command line. But when started from lighttpd, mplayer does not read commands from /srv/mplayer.fifo
. I don't understand why. Here's what I did:
Setup
$ mkfifo /srv/mplayer.fifo
$ chmod o+w /srv/mplayer.fifo
$ ls -l /srv/mplayer.fifo
prw-r--rw- 1 root root 0 Aug 7 12:11 /srv/mplayer.fifo
Test (ran from command line)
$ sudo -u www-data mplayer -ao alsa -slave -input file=/srv/mplayer.fifo -playlist /srv/list -shuffle
$ lsof /srv/mplayer.fifo
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mplayer 21059 www-data 4u FIFO 179,2 0t0 2359331 /srv/mplayer.fifo
$ ps aux | grep mplayer
root 21058 0.0 0.2 4680 2400 pts/0 S+ 12:13 0:00 sudo -u www-data mplayer -ao alsa -slave -input file=/srv/mplayer.fifo -playlist /srv/list -shuffle
www-data 21059 11.6 3.1 127928 30008 pts/0 SL+ 12:13 0:01 mplayer -ao alsa -slave -input file=/srv/mplayer.fifo -playlist /srv/list -shuffle
That's like expected. But if I run mplayer from lighttpd ...
$ cat /var/www/html/play
#!/usr/bin/bash
mplayer -ao alsa -slave -input file=/srv/mplayer.fifo -playlist /srv/list -shuffle &
... **it starts mplayer**, but the mplayer instance is not reading from /srv/mplayer.fifo
. lsof
doesn't produce any output:
$ lsof /srv/mplayer.fifo
$ ps aux | grep mplayer
www-data 21177 15.3 3.1 128212 29744 ? SL 12:30 0:01 mplayer -ao alsa -slave -input file=/srv/mplayer.fifo -playlist /srv/list -shuffle
I can also see mplayer is not reading from the pipe, because writing to it blocks. The mplayer logs don't show anything unusual. Do you have an idea why mplayer doesn't read from the named pipe when run from lighttpd?
Asked by steffen
(121 rep)
Aug 7, 2022, 12:56 PM
Last activity: Aug 15, 2022, 01:02 PM
Last activity: Aug 15, 2022, 01:02 PM