• Error management with a subprocess

    From Jean-Baptiste Gardette@21:1/5 to All on Fri Oct 8 03:05:37 2021
    Hi,

    Windows 7
    Tcl 8.6.11
    java 1.8.0_291

    I create a standalone pipe with chan pipe command to redirect stderr from a subprocess java (executed in background with exec command). See following code :

    lassign [chan pipe] readSide writeSide
    exec ... 2>@ $writeSide &
    close $writeSide
    chan event $readSide readable {
    # read stderr
    }

    I have some questions :
    What is the best way to read the stderr ? read or gets command ?
    If I use the read command, do I configure readSide in non-blocking mode to read without wait an end-of-file ?

    Thank
    Jean-Baptiste

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arjen Markus@21:1/5 to Jean-Baptiste Gardette on Fri Oct 8 04:35:13 2021
    On Friday, October 8, 2021 at 12:05:39 PM UTC+2, Jean-Baptiste Gardette wrote:
    Hi,

    Windows 7
    Tcl 8.6.11
    java 1.8.0_291

    I create a standalone pipe with chan pipe command to redirect stderr from a subprocess java (executed in background with exec command). See following code :

    lassign [chan pipe] readSide writeSide
    exec ... 2>@ $writeSide &
    close $writeSide
    chan event $readSide readable {
    # read stderr
    }

    I have some questions :
    What is the best way to read the stderr ? read or gets command ?
    If I use the read command, do I configure readSide in non-blocking mode to read without wait an end-of-file ?

    Thank
    Jean-Baptiste

    I think you should use the fileevent command (see for instance https://wiki.tcl-lang.org/page/fileevent). The tutorial has a few straightforward examples at https://wiki.tcl-lang.org/page/Tcl+Tutorial+Lesson+26a.

    Regards,

    Arjen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jean-Baptiste Gardette@21:1/5 to All on Fri Oct 8 07:06:38 2021
    Le vendredi 8 octobre 2021 à 13:35:15 UTC+2, arjen.m...@gmail.com a écrit :
    On Friday, October 8, 2021 at 12:05:39 PM UTC+2, Jean-Baptiste Gardette wrote:
    Hi,

    Windows 7
    Tcl 8.6.11
    java 1.8.0_291

    I create a standalone pipe with chan pipe command to redirect stderr from a subprocess java (executed in background with exec command). See following code :

    lassign [chan pipe] readSide writeSide
    exec ... 2>@ $writeSide &
    close $writeSide
    chan event $readSide readable {
    # read stderr
    }

    I have some questions :
    What is the best way to read the stderr ? read or gets command ?
    If I use the read command, do I configure readSide in non-blocking mode to read without wait an end-of-file ?

    Thank
    Jean-Baptiste
    I think you should use the fileevent command (see for instance https://wiki.tcl-lang.org/page/fileevent). The tutorial has a few straightforward examples at https://wiki.tcl-lang.org/page/Tcl+Tutorial+Lesson+26a.

    Regards,

    Arjen

    Thank Arjen, the tutorial is very usefull.

    Jean-Baptiste

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)