Why hangs the web page after it started a daemon o

2019-08-07 18:55发布

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条回答
劳资没心,怎么记你
2楼-- · 2019-08-07 19:28

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

查看更多
登录 后发表回答