summaryrefslogtreecommitdiffstats
path: root/lib/process.tcl
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2023-02-14 07:28:27 +0000
committerOmar Rizwan <omar@omar.website>2023-02-14 07:28:27 +0000
commit3ac7beb4bf551f92aca0358f9bb5fa46876f19c7 (patch)
treeeaf473b476381702f024260a6da58742d5471375 /lib/process.tcl
parentRefactor peering. Refactor process. (diff)
downloadfolk-3ac7beb4bf551f92aca0358f9bb5fa46876f19c7.tar.gz
folk-3ac7beb4bf551f92aca0358f9bb5fa46876f19c7.zip
More cleanup/refactoring of peering.
Start trying to test IPC statements.
Diffstat (limited to 'lib/process.tcl')
-rw-r--r--lib/process.tcl10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/process.tcl b/lib/process.tcl
index 1bca66da..5208384b 100644
--- a/lib/process.tcl
+++ b/lib/process.tcl
@@ -4,15 +4,16 @@ set ::processPrelude {
try $body
after $ms [list after idle [namespace code [info level 0]]]
}
- # TODO: do a socket connection to localhost
-
+
+ source "lib/peer.tcl"
+ peer "localhost"
}
proc On-process {name body} {
namespace eval ::Processes::$name {}
set ::Processes::${name}::name $name
set ::Processes::${name}::body $body
- set ::Processes::${name}::this [uplevel {set this}]
+ set ::Processes::${name}::this [uplevel {expr {[info exists this] ? $this : "<unknown>"}}]
namespace eval ::Processes::$name {
variable tclfd [file tempfile tclfile tclfile.tcl]
puts $tclfd [join [list $::processPrelude $body] "\n"]; close $tclfd
@@ -28,6 +29,7 @@ proc On-process {name body} {
variable log
if {[gets $stdio line] >= 0} {
lappend log $line
+ puts "$name: $line"
Retract process $name has standard output log /l/
Assert process $name has standard output log $log
Step
@@ -36,7 +38,7 @@ proc On-process {name body} {
fconfigure $stdio -blocking 0 -buffering line
fileevent $stdio readable [namespace code handleReadable]
- if {[info exists this]} {
+ if {$this ne "<unknown>"} {
Assert $this is running process $name
}