Minidlna hangs on shutdown on Debian

Posted on 2014/02/04


I have a computer that keeps most of my media; in order to stream these media files to other devices in my LAN (such as the XBMC box in the living room) I use minidlna, which is a very simple “Digital Living Network Alliance” server. The first problem that I had is that minidlna is not currently available for Debian testing (jessie) from official repositories due to missing dependencies, but I installed it anyway from The second problem is that in my common use case I turn on the XBMC and expect it to see the DLNA server immediately, but it did not work. A workaround I found was to restart minidlna with “invoke.rc.d minidlna restart” (as root), and after this command completes XBMC from the other side of my house was able to see it. But minidlna was taking too long to stop. Also, when shutting down the machine, it seemed to hang when trying to stop minidlna. By executing manually the commands in “/etc/init.d/minidlna” I found some problems:

  • the program runs as user minidlna, but this user has no write right in “/var/run/“, and for this reason it can’t write the PID file. Oddly, there was a “/var/run/minidlna/” directory already created (probably during package installation), but it had write permissions only for root. So I chowned the directory to user and group minidlna and changed the init script to create a PID file in that directory.
  • the init script tries to stop the server with start-stop-daemon using “--name minidlna“, but the name of the process was actually minidlnad, so I removed that option.

While solving that, I discovered that minidlna broadcasts a notification of being alive, by default once every 15 minutes, and this is the real reason why the XBMC was not seeing it immediately. I lowered that number to 10 seconds by using “notify_interval=10” in “/etc/minidlna.conf” so that XBMC is able to see it earlier and without restarting the server.

Posted in: Software