Skip to content
Tcl Source Code History Of Ticket 1306694
Login

History Of Ticket 1306694

Artifacts Associated With Ticket 1306694

  1. Ticket change [5877b506d7] (rid 117809) by rbalakri on 2005-09-28 09:32:09:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      When a process is forked and if socket is executed
      within the child process the socket is not accepting
      the incoming connection.
      
      Tcl version: 8.4.11
      Platform: Linux
      
      Tcl Version is compiled with threading enabled. The
      following is the sample server (daytime server) program
      to reproduce the problem,
      
      proc Server {channel clientaddr clientport} {
         puts "Connection from $clientaddr registered"
         puts $channel [clock format [clock seconds]]
         sleep 30
         close $channel
      }
      
      if { [fork] } {
             # Parent
              wait
              exit
      } else {
             # child
              socket -server Server 9900
              puts "child waiting for sockets"
              vwait forever
      }
      
      The corresponding client program,
      
      set server localhost
      set sockChan [socket $server 9900]
      gets $sockChan line
      close $sockChan
      puts "The time on $server is $line"
      
      After the server is started and after starting the
      client netstat comman gives the following output,
      
      [root@myhost test]# netstat -atp | grep 9900
      tcp        0      0 *:9900                      *:*   
                           LISTEN      4309/tcl
      tcp        0      0 myhost:36222          myhost:9900 
               ESTABLISHED 4291/tcl
      tcp        0      0 myhost:9900           myhost:36222
               ESTABLISHED -
      
      The first one is the server's listening socket, second
      is clients socket and third is server's connected
      socket. As you can see the sever's socket doesn't have
      the application associated with it.
      
    4. foundin initialized to: "obsolete: 8.4.11"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "rbalakri"
    9. subsystem initialized to: "24. Channel Commands"
    10. title initialized to: "Sockets are not working in the child processes"
    11. type initialized to: "Bug"
  2. Ticket change [062a105330] (rid 89172) by hobbs on 2005-09-29 00:57:32:

    1. closedate changed to: "2005-09-28T17:57:32"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      Fork and threads are not a valid combination.  If you have a
      threaded build, please use another thread, not fork.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "hobbs"
  3. Ticket change [5bd38fc48c] (rid 118399) by rbalakri on 2005-09-29 11:02:31:

    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"
  4. Ticket change [7cc5639087] (rid 259721) by serhiy.storchaka on 2026-10-21 10:03:37:

    1. icomment:
      Works since 8.5.15 / 8.6.1: after a fork the notifier thread is restarted in the child ([e733a91cdb], [02909e227f], ticket [a0bc856dcd]), so fileevents on sockets fire there.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"