• Stopping process started with open "| command"

    From Cecil Westerhof@21:1/5 to All on Thu Dec 9 11:41:27 2021
    I have a command I start with open "| command".
    I am finished with it before all output is generated.
    If I close it before all output is generated I get (after the command
    is finished):
    child process exited abnormally

    I could solve this with:
    read $fp
    if {[catch {close $fp} closeError]} {
    puts stderr "Could not close speedtest (${closeError})"
    }

    But that only works with a program that does finish.
    (And could be resource unfriendly.)

    What is the correct way to close a program started with:
    open "| command"

    --
    Cecil Westerhof
    Senior Software Engineer
    LinkedIn: http://www.linkedin.com/in/cecilwesterhof

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cecil Westerhof@21:1/5 to Cecil Westerhof on Thu Dec 9 12:14:30 2021
    Cecil Westerhof <Cecil@decebal.nl> writes:

    This is on a Linux system.

    I have a command I start with open "| command".
    I am finished with it before all output is generated.
    If I close it before all output is generated I get (after the command
    is finished):
    child process exited abnormally

    I could solve this with:
    read $fp
    if {[catch {close $fp} closeError]} {
    puts stderr "Could not close speedtest (${closeError})"
    }

    But that only works with a program that does finish.
    (And could be resource unfriendly.)

    What is the correct way to close a program started with:
    open "| command"

    --
    Cecil Westerhof
    Senior Software Engineer
    LinkedIn: http://www.linkedin.com/in/cecilwesterhof

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to Cecil Westerhof on Thu Dec 9 17:46:41 2021
    On 09/12/2021 12:14, Cecil Westerhof wrote:
    Cecil Westerhof <Cecil@decebal.nl> writes:
    What is the correct way to close a program started with:
    open "| command"

    You want TIP #540: https://core.tcl-lang.org/tips/doc/trunk/tip/540.md Unfortunately it is not implemented yet.

    Until that time you will have to use:

    set fd [open "| command"]
    # Do something with $fd
    # ...
    exec kill [pid $fd]


    Schelte.

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