1

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

1 Answers1

0

Your daemon is probably not detaching properly, This SO Answer about daemonizing contains a good summary of the steps required

Community
  • 1
  • 1
Hasturkun
  • 35,395
  • 6
  • 71
  • 104
  • or just add redirection to the bash script –  Feb 09 '11 at 21:37
  • I am sure you are right, that this is an improper detach problem. Since the software is not open source, I cannot fix it. However, the /sbin/start-stop-daemon solved my probem. Thanks! – Marton Sigmond Feb 21 '11 at 21:01