#! /bin/sh
#\
exec tclsh $0

set f [open foo w]
puts $f ashgdfashdgfasdhgfasdhgf
close $f

set f [open foo r]
fconfigure $f -translation binary

set g [open bar w]
fconfigure $g -translation binary -buffering none

proc cmd args {puts stderr CMD:$args;error yo}

proc bgerror args {puts stderr "SUCCESS(bgerror): $args";exit 0}

puts stderr "Initial bar size = [file size bar]"
fcopy $f $g -size 2 -command cmd

set sbs [file size bar]
if {$sbs>0} {set status FAILURE} else {set status SUCCESS}
puts stderr "$status (sync suppression): bar size = $sbs"


after 1000 {puts stderr "FAILURE(bgerror): timeout";exit 1}
vwait forever



