coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed ou


From: Rob Landley
Subject: Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs
Date: Sun, 11 Dec 2022 18:18:36 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0

On 12/9/22 08:26, Carl Edquist via GNU coreutils General Discussion wrote:
>>> Similar to the situation here, i was seeing things annoyingly look like 
>>> they are still 'alive' longer than they ought to be when providing 
>>> input from the terminal.
>>
>> Huh, I never tried that, honestly.
> 
> Here is a simple example:
> 
>      exec 3<> /dev/tcp/example.com/80
> 
>      echo_crlf () { printf "%s\r\n" "$@"; }
> 
>      { echo_crlf "GET / HTTP/1.1"
>        echo_crlf "Host: example.com"
>        echo_crlf "Connection: close"
>        echo_crlf ""
>      } >&3
> 
>      cat <&3
> 
> In this example, i'm sending the input to the socket (on fd 3) directly 
> using the 'printf' builtin and shell redirection, and i request the server 
> close its side of the connection after this request.

This sort of thing is why I added -i to toybox's "timeout" command:

    -i  Only kill for inactivity (restart timeout when command produces output)

It runs the command's stdout through a pipe and does a poll() with the -i
seconds value, and signals the program if the poll() expires.

The android guys found it useful, but I was waiting to hear back about "cut -DF"
before bringing it up here...

Rob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]