From 4758939697498dbdb571c5f0d948edec6ec973ea Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 4 Aug 2013 16:38:53 +0000 Subject: Possible fix for [c4e230f29b] --- unix/tclUnixTest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tclUnixTest.c b/unix/tclUnixTest.c index 2fc1647..d2b729d 100644 --- a/unix/tclUnixTest.c +++ b/unix/tclUnixTest.c @@ -574,8 +574,8 @@ TestforkObjCmd( "Cannot fork", NULL); return TCL_ERROR; } -#ifndef HAVE_PTHREAD_ATFORK - /* Only needed when pthread_atfork is not present. */ +#if !defined(HAVE_PTHREAD_ATFORK) || defined(MAC_OSX_TCL) + /* Only needed when pthread_atfork is not present or on OSX. */ if (pid==0) { Tcl_InitNotifier(); } -- cgit v0.12 From 715175092b503b0a5c1aa902be13f5c279f4551c Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 5 Aug 2013 08:32:57 +0000 Subject: Iron test "unixforkevent-1.1" against forked process stall and file phase issues --- tests/unixForkEvent.test | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/unixForkEvent.test b/tests/unixForkEvent.test index cbe582e..3779c65 100644 --- a/tests/unixForkEvent.test +++ b/tests/unixForkEvent.test @@ -13,8 +13,7 @@ namespace import -force ::tcltest::* testConstraint testfork [llength [info commands testfork]] -# Test if the notifier thread is well initialized in a forked interpreter -# by Tcl_InitNotifier +# Test if the notifier thread is well initialized in a forked interpreter. test unixforkevent-1.1 {fork and test writeable event} \ -constraints testfork \ -body { @@ -24,17 +23,28 @@ test unixforkevent-1.1 {fork and test writeable event} \ # we are the forked process set result initialized set h [open [file join $myFolder test.txt] w] + # create a file event and a timeout which fires after 1 second + # if the file event did not fire fileevent $h writable\ "set result writable;\ after cancel [after 1000 {set result timeout}]" vwait result close $h + # write result file makeFile $result result.txt $myFolder + # write trigger file, that result file is fully written + makeFile "" trigger.txt $myFolder exit } # we are the original process - while {![file readable [file join $myFolder result.txt]]} {} - viewFile result.txt $myFolder + # look over 1.5 seconds for the file creation by the forked process + for {set myTries 0} {$myTries < 15} {incr myTries} { + if {[file readable [file join $myFolder trigger.txt]]} { + return [viewFile result.txt $myFolder] + } + after 100 + } + return "forked process stalled" } \ -result {writable} \ -cleanup { -- cgit v0.12