Why hangs the web page after it started a daemon on the underlying server?

寵の児 提交于 2019-12-24 06:49:54

问题


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:


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



来源:https://stackoverflow.com/questions/4949727/why-hangs-the-web-page-after-it-started-a-daemon-on-the-underlying-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!