cgi program which is a daemon/starting daemon from cgi

cgi program which is a daemon/starting daemon from cgi

Post by korne » Thu, 24 Oct 1996 04:00:00



Hi,

Has anyone tried starting a daemon from a cgi program. I wrote
a daemon and it loads fin from the command line. The parent
process exits as it should and the child keeps running. But
when I try calling the program as a cgi program, the cgi
program (that is the parent process) doesn't seem to exit
until the child also exits. Does anyone know what I need to
do or how I need to write my daemon which is also a cgi
program. Now my browser hangs until the daemon terminates
instead of returning really quickly - ow at least that is
what I have expected.

I tried using nested forks and setsid() but didn't seem to
affect anything.

All help would be greatly appriciated.
--
------------------------------------------------------------

 Chief Technology Officer (CTO)  Fax:   415-547-7735
 NetJet Communications           Phone: 415-547-7730
 Web Publisher to the World      http://www.netjet.com/
 ------------------------------------------------------------

 
 
 

cgi program which is a daemon/starting daemon from cgi

Post by Ken Pizzi » Sun, 27 Oct 1996 04:00:00



>Has anyone tried starting a daemon from a cgi program. I wrote
>a daemon and it loads fin from the command line. The parent
>process exits as it should and the child keeps running. But
>when I try calling the program as a cgi program, the cgi
>program (that is the parent process) doesn't seem to exit
>until the child also exits. Does anyone know what I need to
>do or how I need to write my daemon which is also a cgi
>program. Now my browser hangs until the daemon terminates
>instead of returning really quickly - ow at least that is
>what I have expected.

When I have encountered this kind of behavior before I found that
the Web server had some file descriptor open that it required
the CGI to close before it would recognize the termination of
its child.  In the brief interval between encountering this
problem and switching to a different server I used a brute
force approach to getting around this:

        /* NOTE: you will also need to avoid any other files that you
         * intentionally have open...
         */
        for (i=3; i<1024; ++i) close(i);

Perhaps in conjuction with:
        freopen("/dev/null", "r", stdin);
        freopen("/dev/null", "w", stdout);
        freopen("/dev/null", "w", stderr);

Ugly, but bug/misfeature work-arounds usually are...

                --Ken Pizzini

 
 
 

1. starting daemon from cgi/cgi process that is a daemon

Hi,

Has anyone tried starting a daemon from a cgi program. I wrote
a daemon and it loads fine from the command line. The parent
process exits as it should and the child keeps running. But
when I try calling the program as a cgi program, the cgi
program (that is the parent process) doesn't seem to exit
until the child also exits. Does anyone know what I need to
do or how I need to write my daemon which is also a cgi
program. Now my browser hangs until the daemon terminates
instead of returning really quickly - or at least that is
what I have expected.

I tried using nested forks and setsid() but didn't seem to
affect anything.

All help would be greatly appriciated.
--
------------------------------------------------------------

 Chief Technology Officer (CTO)  Fax:   415-547-7735
 NetJet Communications           Phone: 415-547-7730
 Web Publisher to the World      http://www.netjet.com/
 ------------------------------------------------------------

2. Tux Paint 2002.09.19 available

3. Remote stop and start of daemons from a CGI program

4. Telnet appears but no login prompt

5. /cgi-bin/phf /cgi-bin/test-cgi /cgi-bin/handler

6. slab cleanup

7. Running cgi-bin program as a daemon

8. Open Windows with x86 keyboard

9. start CGI within a CGI ???

10. Communcation (CGI with Daemon)

11. Apache, CGI-Scripts and Daemons

12. Accessing a daemon from a cgi script

13. Cannot execute CGI programs in /cgi-bin with Apache