Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

There was a phone call for you.


comp / comp.lang.tcl / Re: vwait for several channels

SubjectAuthor
* vwait for several channelsLuis Mendes
+* Re: vwait for several channelsRobert Heller
|`- Re: vwait for several channelsLuis Mendes
+* Re: vwait for several channelsRich
|`* Re: vwait for several channelsLuis Mendes
| +- Re: vwait for several channelsHarald Oehlmann
| `* Re: vwait for several channelsRobert Heller
|  `* Re: vwait for several channelsLuis Mendes
|   +- Re: vwait for several channelsHarald Oehlmann
|   +- Re: vwait for several channelsMichael Soyka
|   +- Re: vwait for several channelsRobert Heller
|   `* Re: vwait for several channelset99
|    `- Re: vwait for several channelsLuis Mendes
`* Re: vwait for several channelsundroidwish
 `- Re: vwait for several channelset99

1
Subject: vwait for several channels
From: Luis Mendes
Newsgroups: comp.lang.tcl
Organization: SunSITE.dk - Supporting Open source
Date: Mon, 3 Jun 2024 15:26 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: luisXXXlupeXXX@gmail.com (Luis Mendes)
Subject: vwait for several channels
Newsgroups: comp.lang.tcl
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 03 Jun 2024 15:26:46 GMT
Lines: 16
Message-ID: <665de0b6$0$714$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 8463af99.news.sunsite.dk
X-Trace: 1717428406 news.sunsite.dk 714 luislupe@gmail.com/176.79.85.73:52172
X-Complaints-To: staff@sunsite.dk
View all headers

Hi,

There's a procedure that goes through a list and opens a channel for each
of its elements.
I'd need a vwait for each of the channels, like
vwait exec_0
vwait exec_1
....
0, 1, ... are the execution ids (exec_id).

How can I do this?

Luís Mendes

Subject: Re: vwait for several channels
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Mon, 3 Jun 2024 16:04 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-2.nntp.ord.giganews.com!nntp.giganews.com!local-1.nntp.ord.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 03 Jun 2024 16:04:41 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.17)
Subject: Re: vwait for several channels
In-Reply-To: <665de0b6$0$714$14726298@news.sunsite.dk>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
Newsgroups: comp.lang.tcl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <RRidnQM3yqwHdMD7nZ2dnZfqnPGdnZ2d@giganews.com>
Date: Mon, 03 Jun 2024 16:04:42 +0000
Lines: 33
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-7caSzazp3yR6YQPr7WMNPI+VGCNb4/eHPDafvLTw6em/SHcKfykcPmYRbAiHPLtdB15LP2yI3y74R7q!p6/Qhamfs3AxZmtLuo+xg/f3IgDXMo2G/oewLCKGHN7YSY+SzWscVQOtqUVErjQS3T+qE4ZaWhcx!N6s=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

At 03 Jun 2024 15:26:46 GMT Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:

>
> Hi,
>
>
> There's a procedure that goes through a list and opens a channel for each
> of its elements.
> I'd need a vwait for each of the channels, like
> vwait exec_0
> vwait exec_1
> ...
> 0, 1, ... are the execution ids (exec_id).

Is there any reason to wait for each channel? Will there be code between the
vwaits? Or do you just want to wait until all channels are open?

>
> How can I do this?
>
>
>
> Luís Mendes
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Subject: Re: vwait for several channels
From: Luis Mendes
Newsgroups: comp.lang.tcl
Organization: SunSITE.dk - Supporting Open source
Date: Mon, 3 Jun 2024 17:18 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: luisXXXlupeXXX@gmail.com (Luis Mendes)
Subject: Re: vwait for several channels
Newsgroups: comp.lang.tcl
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<RRidnQM3yqwHdMD7nZ2dnZfqnPGdnZ2d@giganews.com>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 03 Jun 2024 17:18:01 GMT
Lines: 21
Message-ID: <665dfac9$0$708$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 0f5a43ce.news.sunsite.dk
X-Trace: 1717435081 news.sunsite.dk 708 luislupe@gmail.com/176.79.85.73:59956
X-Complaints-To: staff@sunsite.dk
View all headers

On Mon, 03 Jun 2024 16:04:42 +0000, Robert Heller wrote:

> At 03 Jun 2024 15:26:46 GMT Luis Mendes <luisXXXlupeXXX@gmail.com>
> wrote:

>> There's a procedure that goes through a list and opens a channel for
>> each of its elements.
>> I'd need a vwait for each of the channels, like vwait exec_0 vwait
>> exec_1 ...
>> 0, 1, ... are the execution ids (exec_id).
>
> Is there any reason to wait for each channel? Will there be code between
> the vwaits? Or do you just want to wait until all channels are open?
Well, the simple solution could be the latter, but a more fine-grained
option would be the former, as as one channel closes, another can be
opened.
I could learn both, Robert! :-)

Luís

Subject: Re: vwait for several channels
From: Rich
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Mon, 3 Jun 2024 18:01 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Mon, 3 Jun 2024 18:01:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <v3l0da$bkv$1@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
Injection-Date: Mon, 03 Jun 2024 20:01:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f284189086a85cebc68cf2c238848345";
logging-data="11935"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pyqFuuG1cpQQ+Wr0Iv+Uk"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:596mCX4HEWpMgEq3NJym0mXY3C4=
View all headers

Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
> Hi,
>
>
> There's a procedure that goes through a list and opens a channel for each
> of its elements.
> I'd need a vwait for each of the channels, like
> vwait exec_0
> vwait exec_1
> ...
> 0, 1, ... are the execution ids (exec_id).
>
> How can I do this?

You can't vwait on channels. vwait waits on a variable to be changed.

What are you /really/ trying to do?

Subject: Re: vwait for several channels
From: Luis Mendes
Newsgroups: comp.lang.tcl
Organization: SunSITE.dk - Supporting Open source
Date: Tue, 4 Jun 2024 11:34 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: luisXXXlupeXXX@gmail.com (Luis Mendes)
Subject: Re: vwait for several channels
Newsgroups: comp.lang.tcl
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 04 Jun 2024 11:34:37 GMT
Lines: 21
Message-ID: <665efbcd$0$714$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: fe07b8ee.news.sunsite.dk
X-Trace: 1717500877 news.sunsite.dk 714 luislupe@gmail.com/176.79.85.73:65222
X-Complaints-To: staff@sunsite.dk
View all headers

On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:

> Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
>> Hi,
>>
>>
>> There's a procedure that goes through a list and opens a channel for
>> each of its elements.
>> I'd need a vwait for each of the channels, like vwait exec_0 vwait
>> exec_1 ...
>> 0, 1, ... are the execution ids (exec_id).
>>
>> How can I do this?
>
> You can't vwait on channels. vwait waits on a variable to be changed.
>
> What are you /really/ trying to do?
The expression was perhaps too simplistic.
As said in the first message, I want to use several channels at the same
time to perform some 'exec' commands and want to wait for the complete
execution of all of them.

Subject: Re: vwait for several channels
From: Harald Oehlmann
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Tue, 4 Jun 2024 11:50 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortkarg3@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Tue, 4 Jun 2024 13:50:23 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <v3mv1v$bj39$1@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me> <665efbcd$0$714$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 04 Jun 2024 13:50:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4514c0d63109ac9e226e881441a892d1";
logging-data="380009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+F4eOgraPmYx9AcoU2b1xK"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:0Bth7kCBjgOYePHJP4vKhYbDT8I=
Content-Language: en-GB
In-Reply-To: <665efbcd$0$714$14726298@news.sunsite.dk>
View all headers

Am 04.06.2024 um 13:34 schrieb Luis Mendes:
> On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:
>
>> Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
>>> Hi,
>>>
>>>
>>> There's a procedure that goes through a list and opens a channel for
>>> each of its elements.
>>> I'd need a vwait for each of the channels, like vwait exec_0 vwait
>>> exec_1 ...
>>> 0, 1, ... are the execution ids (exec_id).
>>>
>>> How can I do this?
>>
>> You can't vwait on channels. vwait waits on a variable to be changed.
>>
>> What are you /really/ trying to do?
> The expression was perhaps too simplistic.
> As said in the first message, I want to use several channels at the same
> time to perform some 'exec' commands and want to wait for the complete
> execution of all of them.

Then you put a writevent on them and check for the eof and error
conditions to detect, if they got closed from the other side.

Harald

Subject: Re: vwait for several channels
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Tue, 4 Jun 2024 12:33 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-4.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 04 Jun 2024 12:33:10 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.17)
Subject: Re: vwait for several channels
In-Reply-To: <665efbcd$0$714$14726298@news.sunsite.dk>
References: <665de0b6$0$714$14726298@news.sunsite.dk>??<v3l0da$bkv$1@dont-email.me>
<665efbcd$0$714$14726298@news.sunsite.dk>
Newsgroups: comp.lang.tcl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
Date: Tue, 04 Jun 2024 12:33:10 +0000
Lines: 79
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-uGB6Xm3jPD9ONg0of5kfTeL2EyFUo0SJ2vG9201GKjrry76YgzRQgQFY06eQkB1Oqgcqp7zT01m19tL!awCFqIE9uO1vM3IPTj/LXrB8NBUwEJsbuEPn0K5vO9Hy7Zy9QB/Gx4g8w15r5e2rFAaUhvbfdC/j!kaQ=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

At 04 Jun 2024 11:34:37 GMT Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:

>
> On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:
>
> > Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
> >> Hi,
> >>
> >>
> >> There's a procedure that goes through a list and opens a channel for
> >> each of its elements.
> >> I'd need a vwait for each of the channels, like vwait exec_0 vwait
> >> exec_1 ...
> >> 0, 1, ... are the execution ids (exec_id).
> >>
> >> How can I do this?
> >
> > You can't vwait on channels. vwait waits on a variable to be changed.
> >
> > What are you /really/ trying to do?
> The expression was perhaps too simplistic.
> As said in the first message, I want to use several channels at the same
> time to perform some 'exec' commands and want to wait for the complete
> execution of all of them.

You description here is very unclear. 'exec' does not create channels and you
can't "vwait" on a channel anyway.

Maybe what you want is:

# launch a subprocess, capturing its output with a "pipe", which will be read
# by a specified script. The script will have the pipe channel appended to
# it.
proc pipeCommand {commandString commpletionScript} {
if {[catch {open "|$commandString" r} pipe]} {
puts stderr "Error starting $commandString: $pipe"
return
}
fileevent $pipe readable "$commpletionScript $pipe"
}

# read a pipe as data becomes available. Close the pipe when the process
# completes.
proc typicalCompletionProc {pipe} {
if {[gets $pipe line] >= 0} {
puts $line;# one line of output from the process. Maybe parse it?
} else {
# EOF or ERROR on pipe: process completed, possibly with an error
if {[catch {close $pipe} finalResult]} {
# process completed with an error
puts stderr "process completed with an error: $finalResult"
} else {
# process completed with success
puts "process completed: $finalResult"
}
}
}

# fire up some commands in the background, and wait for them to complete
pipeCommand "uname -a" typicalCompletionProc
pipeCommand "ls" typicalCompletionProc
pipeCommand "find $HOME/" typicalCompletionProc
pipeCommand "make" typicalCompletionProc

# enter event loop to allow fileevents to process (read the pipes
# asyncroniously) The variable Forever will never be changed, so this
# statement never returns. Note: if this was done in wish or with
# 'package require Tk', this last line would not be needed at all.
vwait Forever

>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Subject: Re: vwait for several channels
From: Luis Mendes
Newsgroups: comp.lang.tcl
Organization: SunSITE.dk - Supporting Open source
Date: Tue, 4 Jun 2024 14:38 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: luisXXXlupeXXX@gmail.com (Luis Mendes)
Subject: Re: vwait for several channels
Newsgroups: comp.lang.tcl
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me> <665efbcd$0$714$14726298@news.sunsite.dk>
<tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 04 Jun 2024 14:38:42 GMT
Lines: 79
Message-ID: <665f26f2$0$714$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: d4e467d5.news.sunsite.dk
X-Trace: 1717511922 news.sunsite.dk 714 luislupe@gmail.com/176.79.85.73:65222
X-Complaints-To: staff@sunsite.dk
View all headers

On Tue, 04 Jun 2024 12:33:10 +0000, Robert Heller wrote:

> At 04 Jun 2024 11:34:37 GMT Luis Mendes <luisXXXlupeXXX@gmail.com>
> wrote:
>
>
>> On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:
>>
>> > Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
>> >> Hi,
>> >>
>> >>
>> >> There's a procedure that goes through a list and opens a channel for
>> >> each of its elements.
>> >> I'd need a vwait for each of the channels, like vwait exec_0 vwait
>> >> exec_1 ...
>> >> 0, 1, ... are the execution ids (exec_id).
>> >>
>> >> How can I do this?
>> >
>> > You can't vwait on channels. vwait waits on a variable to be
>> > changed.
>> >
>> > What are you /really/ trying to do?
>> The expression was perhaps too simplistic.
>> As said in the first message, I want to use several channels at the
>> same time to perform some 'exec' commands and want to wait for the
>> complete execution of all of them.
>
> You description here is very unclear. 'exec' does not create channels
> and you can't "vwait" on a channel anyway.
>
> Maybe what you want is:
>
> # launch a subprocess, capturing its output with a "pipe", which will be
> read # by a specified script. The script will have the pipe channel
> appended to # it.
> proc pipeCommand {commandString commpletionScript} {
> if {[catch {open "|$commandString" r} pipe]} {
> puts stderr "Error starting $commandString: $pipe"
> return
> }
> fileevent $pipe readable "$commpletionScript $pipe"
> }
>
> # read a pipe as data becomes available. Close the pipe when the process
> # completes.
> proc typicalCompletionProc {pipe} {
> if {[gets $pipe line] >= 0} {
> puts $line;# one line of output from the process. Maybe parse it?
> } else {
> # EOF or ERROR on pipe: process completed, possibly with an error
> if {[catch {close $pipe} finalResult]} {
> # process completed with an error puts stderr "process
> completed with an error: $finalResult"
> } else {
> # process completed with success puts "process completed:
> $finalResult"
> }
> }
> }
>
> # fire up some commands in the background, and wait for them to complete
> pipeCommand "uname -a" typicalCompletionProc pipeCommand "ls"
> typicalCompletionProc pipeCommand "find $HOME/" typicalCompletionProc
> pipeCommand "make" typicalCompletionProc
>
> # enter event loop to allow fileevents to process (read the pipes #
> asyncroniously) The variable Forever will never be changed, so this #
> statement never returns. Note: if this was done in wish or with #
> 'package require Tk', this last line would not be needed at all.
> vwait Forever
I have everything working fine, from opening a channel, to setting up the
readable event, to closing it and setting the variable that vwait is
waiting for, in your example 'Forever'.

What I'd like to know is how to wait for several Forever_$exec_id
variables of channels that are open at the same time.
I just need this last part.

Subject: Re: vwait for several channels
From: Harald Oehlmann
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Tue, 4 Jun 2024 14:52 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortkarg3@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Tue, 4 Jun 2024 16:52:41 +0200
Organization: A noiseless patient Spider
Lines: 98
Message-ID: <v3n9np$bj39$2@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me> <665efbcd$0$714$14726298@news.sunsite.dk>
<tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
<665f26f2$0$714$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 04 Jun 2024 16:52:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4514c0d63109ac9e226e881441a892d1";
logging-data="380009"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8ZtS9UHPpAhqYrhN+FueD"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8huOFg1rwI8dLEU6BDLvgbvZR5s=
Content-Language: en-GB
In-Reply-To: <665f26f2$0$714$14726298@news.sunsite.dk>
View all headers

Am 04.06.2024 um 16:38 schrieb Luis Mendes:
> On Tue, 04 Jun 2024 12:33:10 +0000, Robert Heller wrote:
>
>> At 04 Jun 2024 11:34:37 GMT Luis Mendes <luisXXXlupeXXX@gmail.com>
>> wrote:
>>
>>
>>> On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:
>>>
>>>> Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>>
>>>>> There's a procedure that goes through a list and opens a channel for
>>>>> each of its elements.
>>>>> I'd need a vwait for each of the channels, like vwait exec_0 vwait
>>>>> exec_1 ...
>>>>> 0, 1, ... are the execution ids (exec_id).
>>>>>
>>>>> How can I do this?
>>>>
>>>> You can't vwait on channels. vwait waits on a variable to be
>>>> changed.
>>>>
>>>> What are you /really/ trying to do?
>>> The expression was perhaps too simplistic.
>>> As said in the first message, I want to use several channels at the
>>> same time to perform some 'exec' commands and want to wait for the
>>> complete execution of all of them.
>>
>> You description here is very unclear. 'exec' does not create channels
>> and you can't "vwait" on a channel anyway.
>>
>> Maybe what you want is:
>>
>> # launch a subprocess, capturing its output with a "pipe", which will be
>> read # by a specified script. The script will have the pipe channel
>> appended to # it.
>> proc pipeCommand {commandString commpletionScript} {
>> if {[catch {open "|$commandString" r} pipe]} {
>> puts stderr "Error starting $commandString: $pipe"
>> return
>> }
>> fileevent $pipe readable "$commpletionScript $pipe"
>> }
>>
>> # read a pipe as data becomes available. Close the pipe when the process
>> # completes.
>> proc typicalCompletionProc {pipe} {
>> if {[gets $pipe line] >= 0} {
>> puts $line;# one line of output from the process. Maybe parse it?
>> } else {
>> # EOF or ERROR on pipe: process completed, possibly with an error
>> if {[catch {close $pipe} finalResult]} {
>> # process completed with an error puts stderr "process
>> completed with an error: $finalResult"
>> } else {
>> # process completed with success puts "process completed:
>> $finalResult"
>> }
>> }
>> }
>>
>> # fire up some commands in the background, and wait for them to complete
>> pipeCommand "uname -a" typicalCompletionProc pipeCommand "ls"
>> typicalCompletionProc pipeCommand "find $HOME/" typicalCompletionProc
>> pipeCommand "make" typicalCompletionProc
>>
>> # enter event loop to allow fileevents to process (read the pipes #
>> asyncroniously) The variable Forever will never be changed, so this #
>> statement never returns. Note: if this was done in wish or with #
>> 'package require Tk', this last line would not be needed at all.
>> vwait Forever
> I have everything working fine, from opening a channel, to setting up the
> readable event, to closing it and setting the variable that vwait is
> waiting for, in your example 'Forever'.
>
> What I'd like to know is how to wait for several Forever_$exec_id
> variables of channels that are open at the same time.
> I just need this last part.

Hi Luis,
it is quite uncommon to use a vwait for this.
The example uses "vwait forever" just to start the event loop.
If you are using Tk, this is not required. There is always an event loop.

To find out when all of your commands ended:
- create a data structure like a global list which keeps track of all
open tasks. If a task finishes, remove it from the data structure.
If the list is empty, you are gone. This should be done in the event
procedure.
If you want the vwait in the example to end, you may execute in this case:
set ::forever 1

As "vwait forever" waits that a variable called "forever" is changed.

Thank you and take care,
Harald

Subject: Re: vwait for several channels
From: Michael Soyka
Newsgroups: comp.lang.tcl
Organization: self
Date: Tue, 4 Jun 2024 15:00 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mssr953@gmail.com (Michael Soyka)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Tue, 4 Jun 2024 11:00:14 -0400
Organization: self
Lines: 83
Message-ID: <v3na5u$fhgb$1@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me> <665efbcd$0$714$14726298@news.sunsite.dk>
<tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
<665f26f2$0$714$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 04 Jun 2024 17:00:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bbe5025ecf4da4b222eb830bdc06efdc";
logging-data="509451"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Fnr0SspGm2MXYXwm0SQir"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:IKagaZXoAOtFo4N503nD61h+Cg4=
Content-Language: en-US
In-Reply-To: <665f26f2$0$714$14726298@news.sunsite.dk>
View all headers

On 06/04/2024 10:38 AM, Luis Mendes wrote:
> On Tue, 04 Jun 2024 12:33:10 +0000, Robert Heller wrote:
>
>> At 04 Jun 2024 11:34:37 GMT Luis Mendes <luisXXXlupeXXX@gmail.com>
>> wrote:
>>
>>
>>> On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:
>>>
>>>> Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
>>>>> Hi,
>>>>>
>>>>>
>>>>> There's a procedure that goes through a list and opens a channel for
>>>>> each of its elements.
>>>>> I'd need a vwait for each of the channels, like vwait exec_0 vwait
>>>>> exec_1 ...
>>>>> 0, 1, ... are the execution ids (exec_id).
>>>>>
>>>>> How can I do this?
>>>>
>>>> You can't vwait on channels. vwait waits on a variable to be
>>>> changed.
>>>>
>>>> What are you /really/ trying to do?
>>> The expression was perhaps too simplistic.
>>> As said in the first message, I want to use several channels at the
>>> same time to perform some 'exec' commands and want to wait for the
>>> complete execution of all of them.
>>
>> You description here is very unclear. 'exec' does not create channels
>> and you can't "vwait" on a channel anyway.
>>
>> Maybe what you want is:
>>
>> # launch a subprocess, capturing its output with a "pipe", which will be
>> read # by a specified script. The script will have the pipe channel
>> appended to # it.
>> proc pipeCommand {commandString commpletionScript} {
>> if {[catch {open "|$commandString" r} pipe]} {
>> puts stderr "Error starting $commandString: $pipe"
>> return
>> }
>> fileevent $pipe readable "$commpletionScript $pipe"
>> }
>>
>> # read a pipe as data becomes available. Close the pipe when the process
>> # completes.
>> proc typicalCompletionProc {pipe} {
>> if {[gets $pipe line] >= 0} {
>> puts $line;# one line of output from the process. Maybe parse it?
>> } else {
>> # EOF or ERROR on pipe: process completed, possibly with an error
>> if {[catch {close $pipe} finalResult]} {
>> # process completed with an error puts stderr "process
>> completed with an error: $finalResult"
>> } else {
>> # process completed with success puts "process completed:
>> $finalResult"
>> }
>> }
>> }
>>
>> # fire up some commands in the background, and wait for them to complete
>> pipeCommand "uname -a" typicalCompletionProc pipeCommand "ls"
>> typicalCompletionProc pipeCommand "find $HOME/" typicalCompletionProc
>> pipeCommand "make" typicalCompletionProc
>>
>> # enter event loop to allow fileevents to process (read the pipes #
>> asyncroniously) The variable Forever will never be changed, so this #
>> statement never returns. Note: if this was done in wish or with #
>> 'package require Tk', this last line would not be needed at all.
>> vwait Forever
> I have everything working fine, from opening a channel, to setting up the
> readable event, to closing it and setting the variable that vwait is
> waiting for, in your example 'Forever'.
>
> What I'd like to know is how to wait for several Forever_$exec_id
> variables of channels that are open at the same time.
> I just need this last part.
What about making your vwait variable a countdown variable- initialize
it to the number of channels, have the channel handlers decrement it
when they close, and repeat the vwait call until the value becomes zero?

Subject: Re: vwait for several channels
From: Robert Heller
Newsgroups: comp.lang.tcl
Organization: Deepwoods Software
Date: Tue, 4 Jun 2024 15:32 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!border-3.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 04 Jun 2024 15:32:29 +0000
MIME-Version: 1.0
From: heller@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.17)
Subject: Re: vwait for several channels
In-Reply-To: <665f26f2$0$714$14726298@news.sunsite.dk>
References: <665de0b6$0$714$14726298@news.sunsite.dk>??<v3l0da$bkv$1@dont-email.me>
<665efbcd$0$714$14726298@news.sunsite.dk>??<tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
<665f26f2$0$714$14726298@news.sunsite.dk>
Newsgroups: comp.lang.tcl
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <PVqdnf_AkaEQrsL7nZ2dnZfqnPqdnZ2d@giganews.com>
Date: Tue, 04 Jun 2024 15:32:29 +0000
Lines: 123
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Dq0OUlX+bg6uYWP1otJr37SQN/tVvaIbNooeWdDPNIdQt8B9OYoxc/X1bX2NaJ2bBcKIDXDlhoi+ZGa!kqdCBQa6gIHMlLj8l+HhZ8qAJHZT/oLb8Quxm+FSlTbstTS2jtXVVk9afCnSerzoi5VFUwvxIh7m!mZA=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

At 04 Jun 2024 14:38:42 GMT Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:

>
> On Tue, 04 Jun 2024 12:33:10 +0000, Robert Heller wrote:
>
> > At 04 Jun 2024 11:34:37 GMT Luis Mendes <luisXXXlupeXXX@gmail.com>
> > wrote:
> >
> >
> >> On Mon, 3 Jun 2024 18:01:14 -0000 (UTC), Rich wrote:
> >>
> >> > Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
> >> >> Hi,
> >> >>
> >> >>
> >> >> There's a procedure that goes through a list and opens a channel for
> >> >> each of its elements.
> >> >> I'd need a vwait for each of the channels, like vwait exec_0 vwait
> >> >> exec_1 ...
> >> >> 0, 1, ... are the execution ids (exec_id).
> >> >>
> >> >> How can I do this?
> >> >
> >> > You can't vwait on channels. vwait waits on a variable to be
> >> > changed.
> >> >
> >> > What are you /really/ trying to do?
> >> The expression was perhaps too simplistic.
> >> As said in the first message, I want to use several channels at the
> >> same time to perform some 'exec' commands and want to wait for the
> >> complete execution of all of them.
> >
> > You description here is very unclear. 'exec' does not create channels
> > and you can't "vwait" on a channel anyway.
> >
> > Maybe what you want is:
> >
> > # launch a subprocess, capturing its output with a "pipe", which will be
> > read # by a specified script. The script will have the pipe channel
> > appended to # it.
> > proc pipeCommand {commandString commpletionScript} {
> > if {[catch {open "|$commandString" r} pipe]} {
> > puts stderr "Error starting $commandString: $pipe"
> > return
> > }
> > fileevent $pipe readable "$commpletionScript $pipe"
> > }
> >
> > # read a pipe as data becomes available. Close the pipe when the process
> > # completes.
> > proc typicalCompletionProc {pipe} {
> > if {[gets $pipe line] >= 0} {
> > puts $line;# one line of output from the process. Maybe parse it?
> > } else {
> > # EOF or ERROR on pipe: process completed, possibly with an error
> > if {[catch {close $pipe} finalResult]} {
> > # process completed with an error puts stderr "process
> > completed with an error: $finalResult"
> > } else {
> > # process completed with success puts "process completed:
> > $finalResult"
> > }
> > }
> > }
> >
> > # fire up some commands in the background, and wait for them to complete
> > pipeCommand "uname -a" typicalCompletionProc pipeCommand "ls"
> > typicalCompletionProc pipeCommand "find $HOME/" typicalCompletionProc
> > pipeCommand "make" typicalCompletionProc
> >
> > # enter event loop to allow fileevents to process (read the pipes #
> > asyncroniously) The variable Forever will never be changed, so this #
> > statement never returns. Note: if this was done in wish or with #
> > 'package require Tk', this last line would not be needed at all.
> > vwait Forever
> I have everything working fine, from opening a channel, to setting up the
> readable event, to closing it and setting the variable that vwait is
> waiting for, in your example 'Forever'.

Why are you bothering to set the Forever variable?

>
> What I'd like to know is how to wait for several Forever_$exec_id
> variables of channels that are open at the same time.
> I just need this last part.

Exactly why do you need to do this? What are you *really* trying to do? And
why? The reader proc can handle any process rundown and whatever post process
processing.

If all you want is for the program to terminate when all of the processes
complete, then you can set a counter to the total number of them, and
decrement that counter in the reader proc when it closes the pipe and then
have a loop at the end like:

set totalProc 10

# 10x start process
# the commpletion procs decrement totalProc: "incr ::totalProc -1"

# then:

while {$totalProc > 0} {
vwait totalProc
}

This should do what you want.

It is not meaningful to have multiple vwaits -- that just makes no sense. The
processes are asyncronious and won't terminate in order, so having the vwaits
in order won't work. You should only vwait on a single variable. Using it
as a global counter will work to wait for each process, even if they finish
"out of order". You would stop waiting when the count reaches 0.

>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Subject: Re: vwait for several channels
From: undroidwish
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 5 Jun 2024 04:32 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: undroidwish@googlemail.com (undroidwish)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Wed, 5 Jun 2024 06:32:38 +0200
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <v3opp7$qtul$1@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 05 Jun 2024 06:32:40 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="65c904ecf53cee0e20a132c5bfbe3291";
logging-data="882645"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gNeyUn0V7ZJUCfyLOCzk+8tT7BDKiTdQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.10.0
Cancel-Lock: sha1:DTVXfaqXtvs0cL2mRRWEvxLfcbk=
In-Reply-To: <665de0b6$0$714$14726298@news.sunsite.dk>
Content-Language: en-US
View all headers

On 6/3/24 17:26, Luis Mendes wrote:

> ...
> I'd need a vwait for each of the channels, like
> vwait exec_0
> vwait exec_1
> ...
> 0, 1, ... are the execution ids (exec_id).
>
> How can I do this?

Might be a pattern for which TIP#455 could be of use, see

https://core.tcl-lang.org/tips/doc/trunk/tip/455.md

Cheers,
Christian

Subject: Re: vwait for several channels
From: et99
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 5 Jun 2024 04:55 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Tue, 4 Jun 2024 21:55:40 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <v3or4c$r3ja$1@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me> <665efbcd$0$714$14726298@news.sunsite.dk>
<tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
<665f26f2$0$714$14726298@news.sunsite.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 05 Jun 2024 06:55:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="346a62f56e9272613c989d490fe13b46";
logging-data="888426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tcD25ep5woQyC68xImqQy"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:RtmmXXfxfX12GnxYG45E3vEkHPA=
Content-Language: en-US
In-Reply-To: <665f26f2$0$714$14726298@news.sunsite.dk>
View all headers

On 6/4/2024 7:38 AM, Luis Mendes wrote:
-snip-
> I have everything working fine, from opening a channel, to setting up the
> readable event, to closing it and setting the variable that vwait is
> waiting for, in your example 'Forever'.
>
> What I'd like to know is how to wait for several Forever_$exec_id
> variables of channels that are open at the same time.
> I just need this last part.

I do the following to wait for multiple threads to *ALL* complete some job; it should also work with processes.

Assume some proc, for example startit, creates a processN (or threadN) and endN is the variable that is set when the process (or thread) finishes:

unset -nocomplain end1 ;# variable that is set to some value when process1 is done
startit process1 end1

unset -nocomplain end2 ;# ditto
startit process2 end2

unset -nocomplain end3 ;# ditto
startit process3 end3

.... and so on

# now when you want to wait for *ALL* of them (the order of these does not matter)

if {![info exist end1]} {vwait end1}
if {![info exist end2]} {vwait end2}
if {![info exist end3]} {vwait end3}

..... and so on

By unsetting each variable first, a potential race condition deadlock is avoided. It also doesn't matter which one finishes first or even if they've all finished by the time you need to wait for all of them (in case if you want to do something else before waiting).

To understand why this approach is needed, suppose that while you are vwaiting for the first one, the 2nd or 3rd ones finish first and set their corresponding variables to some value.

Upon continuing after end1 is set, if you were to vwait for either of end2 or end3 *after* they were already set, you would wait forever. You avoid that because you are testing for the variable having been already set *before* vwaiting on that variable. That's why you unset first, so you can do the [info exist] test before vwaiting.

The rest of the code you say is complete, and is compatible with the above method.

Subject: Re: vwait for several channels
From: et99
Newsgroups: comp.lang.tcl
Organization: A noiseless patient Spider
Date: Wed, 5 Jun 2024 05:11 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: vwait for several channels
Date: Tue, 4 Jun 2024 22:11:38 -0700
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <v3os2a$r3ja$2@dont-email.me>
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3opp7$qtul$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 05 Jun 2024 07:11:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="346a62f56e9272613c989d490fe13b46";
logging-data="888426"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YBVEPXJxR0F9ylEPqZk+J"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:rkh5dVhswH8Cxb45WEdNDvq2IWE=
In-Reply-To: <v3opp7$qtul$1@dont-email.me>
Content-Language: en-US
View all headers

On 6/4/2024 9:32 PM, undroidwish wrote:
> On 6/3/24 17:26, Luis Mendes wrote:
>
>> ...
>> I'd need a vwait for each of the channels, like
>> vwait exec_0
>> vwait exec_1
>> ...
>> 0, 1, ... are the execution ids (exec_id).
>>
>> How can I do this?
>
> Might be a pattern for which TIP#455 could be of use, see
>
>   https://core.tcl-lang.org/tips/doc/trunk/tip/455.md
>
> Cheers,
> Christian

I have considered writing a TIP that would enhance vwait with one more option (I don't see it in TIP 455)

vwait -ifnotset variable

This would be equivalent to the code I use where I unset a variable and then do:

if {![info exist variable]} {vwait variable}

which works only because I know that the if and info statements are essentially atomic with respect to the event loop. I doubt that would ever change, but it's still an undocumented (afaik) assumption I have been making.

-e

Subject: Re: vwait for several channels
From: Luis Mendes
Newsgroups: comp.lang.tcl
Organization: SunSITE.dk - Supporting Open source
Date: Thu, 6 Jun 2024 14:04 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!weretis.net!feeder8.news.weretis.net!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: luisXXXlupeXXX@gmail.com (Luis Mendes)
Subject: Re: vwait for several channels
Newsgroups: comp.lang.tcl
References: <665de0b6$0$714$14726298@news.sunsite.dk>
<v3l0da$bkv$1@dont-email.me> <665efbcd$0$714$14726298@news.sunsite.dk>
<tdecnUDftecblML7nZ2dnZfqnPqdnZ2d@giganews.com>
<665f26f2$0$714$14726298@news.sunsite.dk> <v3or4c$r3ja$1@dont-email.me>
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 06 Jun 2024 14:04:23 GMT
Lines: 57
Message-ID: <6661c1e6$0$705$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 4f98cb0a.news.sunsite.dk
X-Trace: 1717682663 news.sunsite.dk 705 luislupe@gmail.com/176.79.85.73:52351
X-Complaints-To: staff@sunsite.dk
View all headers

On Tue, 4 Jun 2024 21:55:40 -0700, et99 wrote:

> On 6/4/2024 7:38 AM, Luis Mendes wrote:
> -snip-
>> I have everything working fine, from opening a channel, to setting up
>> the readable event, to closing it and setting the variable that vwait
>> is waiting for, in your example 'Forever'.
>>
>> What I'd like to know is how to wait for several Forever_$exec_id
>> variables of channels that are open at the same time.
>> I just need this last part.
>
>
> I do the following to wait for multiple threads to *ALL* complete some
> job; it should also work with processes.
>
> Assume some proc, for example startit, creates a processN (or threadN)
> and endN is the variable that is set when the process (or thread)
> finishes:
>
> unset -nocomplain end1 ;# variable that is set to some value when
> process1 is done startit process1 end1
>
> unset -nocomplain end2 ;# ditto startit process2 end2
>
> unset -nocomplain end3 ;# ditto startit process3 end3
>
> ... and so on
>
> # now when you want to wait for *ALL* of them (the order of these does
> not matter)
>
> if {![info exist end1]} {vwait end1}
> if {![info exist end2]} {vwait end2}
> if {![info exist end3]} {vwait end3}
>
> .... and so on
>
> By unsetting each variable first, a potential race condition deadlock is
> avoided. It also doesn't matter which one finishes first or even if
> they've all finished by the time you need to wait for all of them (in
> case if you want to do something else before waiting).
>
> To understand why this approach is needed, suppose that while you are
> vwaiting for the first one, the 2nd or 3rd ones finish first and set
> their corresponding variables to some value.
>
> Upon continuing after end1 is set, if you were to vwait for either of
> end2 or end3 *after* they were already set, you would wait forever. You
> avoid that because you are testing for the variable having been already
> set *before* vwaiting on that variable. That's why you unset first, so
> you can do the [info exist] test before vwaiting.
>
> The rest of the code you say is complete, and is compatible with the
> above method.

Thank you all for your suggestions!

1

rocksolid light 0.9.8
clearnet tor