I would like to start/stop a daemon process on my home server via a simple web page.
The html is like this:
<form action="http://192.168.2.101/cgi-bin/managedaemon.pl" method="post">
<input type="submit" value="Start" name="start"/>
<input type="submit" value="Stop" name="stop"/>
</form>
The managedaemon.pl is like this:
#!/usr/bin/perl
system("/usr/local/theprog/startserver");
print "Content-type:text/html\r\n\r\n";
print "<html>";
...
And the startserver is like this:
#!/bin/bash
cd /usr/local/theprog
./theprogserver -daemon
When I execute the Perl script from the command line, the daemon process is started properly and the script is terminated.
However, when I trigger it from the web browser, the daemon process is started, but the page hangs until the just started daemon is killed.
Please let me know how could I avoid this 'hanging'.
Thanks, Marton
Your daemon is probably not detaching properly, This SO Answer about daemonizing contains a good summary of the steps required