[FFmpeg-devel] [PATCH] ffmpeg: modify tty state when stderr is redirected

Hendrik Leppkes h.leppkes at gmail.com
Mon Aug 3 16:40:04 CEST 2015


On Mon, Aug 3, 2015 at 4:34 PM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
> On Sat, Aug 1, 2015 at 6:54 AM, Nicolas George <george at nsup.org> wrote:
>> Le quartidi 14 thermidor, an CCXXIII, Michael Niedermayer a écrit :
>>> > ffmpeg -lavfi testsrc -f framecrc | head
>>> Thats interresting, i tried this and it did not trash my terminal
>>> also ive almost never seen ffmpeg trash my terminal with the current
>>> code. No matter how i run it
>>
>> As Ganesh noticed, I forgot the output "-" in my example, but you probably
>> noticed that on your own, and that is not the issue.
>>
>> I just ran some tests and it appears that bash restores the tty state if the
>> command was killed by a signal but not if it exited normally.
>>
>> Therefore, "ffmpeg ... - | head" will have the tty restored because ffmpeg
>> dies by SIGPIPE, but "strace ffmpeg ... - | head" will trash the tty state
>> because bash does not know of the SIGPIPE. The same goes for anything that
>> runs ffmpeg as a sub-process, from "sh -c ..." to the FATE harness.
>>
>> Well, bash does part of its job, but I consider it should do more: leaving
>> the tty trashed just because you inserted strace in front of the command is
>> bad policy.
>
> Above example shows that even without this patch, tty state can be trashed.
> Thus tty trashing is unavoidable, and only fix for this is via shell
> configuration (see patch 2/3).
> Therefore this patch should be included to fix Ticket2964.

Trashing the state even more often just because there is one example
where this can already happen is not a valid reasoning.

- Hendrik


More information about the ffmpeg-devel mailing list