Question about socket syscall in release 6.2

Martin Candurra martincad at
Tue Apr 29 14:36:23 UTC 2008

I have found some weird behavior about the socket system call in freebsd
release 6.2.
The problem appears if I try to open more sockets than the ulimits allows:
the socket system call gets blocked instead of returning an EMFILE error.

This only happens to me in release 6.2 ( I tested in 7.0 but it works fine).
The following python script is what I have used to reproduce the issue:

import os
import socket
from random import randint
import sys
socketAddress = ("", randint(20000, 30000))

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

socketList = []
child = -1
for i in range(10000):

    child = os.fork()
    if (child):
        clientCon, address = s.accept()
        os.waitpid(0, os.WNOHANG)
        print "child %d" % i
        clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        if (clientSocket==-1):
            print("client socket error")
        err = clientSocket.connect(socketAddress)
        if (err==-1):
            print("client connect error")

Is there something I'm missing ? Can someone shed me some light about this ?

Thanks in advance.

Best regards.

More information about the freebsd-questions mailing list