Artifacts Associated With Ticket 1306694
Ticket change [5877b506d7] (rid 117809) by rbalakri on 2005-09-28 09:32:09:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- 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. - foundin initialized to: "obsolete: 8.4.11"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "rbalakri"
- subsystem initialized to: "24. Channel Commands"
- title initialized to: "Sockets are not working in the child processes"
- type initialized to: "Bug"
Ticket change [062a105330] (rid 89172) by hobbs on 2005-09-29 00:57:32:
- closedate changed to: "2005-09-28T17:57:32"
- closer changed to: "hobbs"
- 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.
- login: "hobbs"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "hobbs"
Ticket change [5bd38fc48c] (rid 118399) by rbalakri on 2005-09-29 11:02:31:
- 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 } - login: "rbalakri"
- mimetype: "text/plain"
- status changed to: "Open"
- username: "rbalakri"
- icomment:
Ticket change [7cc5639087] (rid 259721) by serhiy.storchaka on 2026-10-21 10:03:37:
- 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.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- icomment: