Bug #1716

mod_scgi process spawning without replacing fd=0 (stdin) by socket as in fcgi

Added by Anonymous over 7 years ago. Updated over 7 years ago.

Status:FixedStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:1.4.20
Missing in 1.5.x:


mod_scgi is quite similar to mod_fastcgi however, it has an important issue:

When scgi process is spawned its stdin fd do not replaced with socket.

Little description: there are two ways to connect to f/scgi process:

1. By predefined socket

2. By opening stdin as an input socket: this method is usually used in
most of cases when lighty spwans fastcgi process.

So operations are:

1. Create socket /tmp/somesock

2. Bind to socket

3. Fork a process

4. Close fd=0 and copy our new socket to fd=0 (stdin) by dup2

5. Exec a process when fd=0 is socket and fastcgi process can call accept(2)
on this fd (part of standard fastcgi method)

However 4th step is not done in case of scgi which makes facility of spawning of several scgi process by web server quite usless (unless I accidentially guess
what is the socket should be opened for lighty)

-- artyomtnk

mod_scgi.patch Magnifier - Patch that fixes the issue -- artyomtnk (362 Bytes) Anonymous, 2008-07-11 15:34


#1 Updated by Anonymous over 7 years ago

Simple code to reproduce the problem:

Lighttpd configuration:

server.modules              = ("mod_scgi")
server.document-root        = "./" 
server.port = 8080
server.bind = "" 

scgi.server = ( "/bb" =>
( "localhost" => (
      "check-local" => "disable",
      "bin-path" => "./a.out",
      "socket" => "/tmp/bb-fastcgi.socket" 

VERY Simple C SCGI application:

#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>

char buffer[16384];

int main()
        for(;;) {
                int s=accept(0,NULL,NULL);
                if(s<0) {
                char const msg[]="Content-Type: text/html\r\n\r\n<h1>Hello World</h1>\r\n";



Before patch application exists with the error.

After, accessing to works fine

-- artyomtnk

#2 Updated by Anonymous over 7 years ago


Is there any chance that the issue will be fixed?
This bug makes server side scgi process spawning useless.

#3 Updated by stbuehler over 7 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

Fixed in r2257

Also available in: Atom