set ::unixjobs [dict create] set ::nextunixjobid 0 proc ::readline {jobid channel} { if {[gets $channel line] >= 0} { dict with ::unixjobs $jobid { lappend log $line Retract $object is running Unix command $command with job id $jobid output /something/ Assert $object is running Unix command $command with job id $jobid output $log Step } } elseif {[eof $channel]} { close $channel } } When /someone/ wishes /p/ runs Unix command /c/ { set jobid [incr ::nextunixjobid] dict set ::unixjobs $jobid [dict create object $p command $c log [list]] lassign [chan pipe] reader writer set pid [exec {*}$c >@$writer 2>@1 &] close $writer fconfigure $reader -blocking 0 fileevent $reader readable [list ::readline $jobid $reader] When /p/ is running Unix command /c/ with job id $jobid output /log/ { Wish $p is labelled [join $log "\n"] } On unmatch [list exec kill $pid] }