[FFmpeg-devel] [PATCH] ffmpeg: use isatty() before messing with the terminal state

Michael Niedermayer michaelni at gmx.at
Wed Jun 6 12:39:47 CEST 2012


On Wed, Jun 06, 2012 at 09:27:14AM +0200, Reimar Döffinger wrote:
> On 6 Jun 2012, at 03:55, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Tue, Jun 05, 2012 at 08:36:50PM +0200, François Revol wrote:
> >> On 05/06/2012 20:24, Michael Niedermayer wrote:
> >>> This fixes terminal messup in case of crashes (like in make fate)
> >>> 
> >>> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> >>> ---
> >>> ffmpeg.c |    4 +++-
> >>> 1 file changed, 3 insertions(+), 1 deletion(-)
> >>> 
> >>> diff --git a/ffmpeg.c b/ffmpeg.c
> >>> index a897c9e..8d5c1af 100644
> >>> --- a/ffmpeg.c
> >>> +++ b/ffmpeg.c
> >>> @@ -1369,7 +1369,9 @@ static void term_init(void)
> >>> #if HAVE_TERMIOS_H
> >>>     if(!run_as_daemon){
> >>>         struct termios tty;
> >>> -
> >>> +#if HAVE_ISATTY
> >>> +        if(isatty(0) && isatty(2))
> >>> +#endif
> >>>         if (tcgetattr (0, &tty) == 0) {
> >>>             oldtty = tty;
> >>>             restore_tty = 1;
> >> 
> >> indentation seems odd but on the principle this looks ok to me.
> > 
> > dunno what i could do about the indention, reindenting the code
> > after the #if#else would look odd too i think, so ill leave the
> > indention for now
> 
> Just avoid the issue? These kind of ifs are confusing anyway and easy to break, better to avoid them in the first place. E.g.

locally fixed
thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Let us carefully observe those good qualities wherein our enemies excel us
and endeavor to excel them, by avoiding what is faulty, and imitating what
is excellent in them. -- Plutarch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120606/d8ea9ab8/attachment.asc>


More information about the ffmpeg-devel mailing list