Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 5bd38fc48c46220e0d9bd47dcedf175447abfa9b
Ticket: 1306694fffffffffffffffffffffffffffffffff
Sockets are not working in the child processes
User & Date: rbalakri on 2005-09-29 11:02:31
Changes

  1. icomment:
    Logged In: YES 
    user_id=431412
    
    I've threaded server (for each client connection a worker
    thread will be created to handle the client request) and I
    want to daemoize the server.
    
    For that I'm using the following piece of procedure. Can you
    suggest some alternatives if what I'm doing is not correct ?
    
    daemonize
    signal ignore SIGHUP
    signal unblock {SIGQUIT SIGTERM}
    signal trap {SIGQUIT SIGTERM} [subst {shutdown $arg(immediate)}]
    my_server <server args>
    
    proc daemonize {} {
    
        global data
    
        if {[fork]} {
            exit 0
        }
        id process group set
        signal ignore SIGHUP
        if {[fork]} {
            # child doesn't get exited and gets into a mutex
            # deadlock when --enable-threads is enabled while
    TCL compilation
            # see bug ids 923072 and 749639 in sourceforge.net
            kill SIGKILL [pid]
            exit 0
        }
        close stdin
        close stdout
        close stderr
        set fd [open /dev/null r]
        set fd [open /dev/null w]
        set fd [open /dev/null w]
        cd /
        umask 022
        return [id process]
    }
    
    proc shutdown { immediate } {
          # Check if all the worker threads are shutdown
          # and then exit the process
    }
    
    
  2. login: "rbalakri"
  3. mimetype: "text/plain"
  4. status changed to: "Open"
  5. username: "rbalakri"