- /* Set-up tty signal handler to be aware of tty changes */
- memset( &sig_tty, 0, sizeof( sig_tty ) );
- sig_tty.sa_handler = SwitchDisplay;
- sigemptyset( &sig_tty.sa_mask );
- if( sigaction( SIGUSR1, &sig_tty, &p_vout->p_sys->sig_usr1 ) ||
- sigaction( SIGUSR2, &sig_tty, &p_vout->p_sys->sig_usr2 ) )
+ if( tcsetattr(0, TCSAFLUSH, &new_termios) == -1 )
+ {
+ msg_Err( p_vout, "tcsetattr failed" );
+ }
+
+ ioctl( p_sys->i_tty, VT_RELDISP, VT_ACKACQ );
+
+ /* Set-up tty signal handler to be aware of tty changes */
+ memset( &sig_tty, 0, sizeof( sig_tty ) );
+ sig_tty.sa_handler = SwitchDisplay;
+ sigemptyset( &sig_tty.sa_mask );
+ if( sigaction( SIGUSR1, &sig_tty, &p_vout->p_sys->sig_usr1 ) ||
+ sigaction( SIGUSR2, &sig_tty, &p_vout->p_sys->sig_usr2 ) )
+ {
+ msg_Err( p_vout, "cannot set signal handler (%m)" );
+ tcsetattr(0, 0, &p_vout->p_sys->old_termios);
+ TextMode( p_sys->i_tty );
+ free( p_vout->p_sys );
+ return VLC_EGENERIC;
+ }
+
+ /* Set-up tty according to new signal handler */
+ if( -1 == ioctl( p_sys->i_tty, VT_GETMODE, &p_vout->p_sys->vt_mode ) )
+ {
+ msg_Err( p_vout, "cannot get terminal mode (%m)" );
+ sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
+ sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
+ tcsetattr(0, 0, &p_vout->p_sys->old_termios);
+ TextMode( p_sys->i_tty );
+ free( p_vout->p_sys );
+ return VLC_EGENERIC;
+ }
+ memcpy( &vt_mode, &p_vout->p_sys->vt_mode, sizeof( vt_mode ) );
+ vt_mode.mode = VT_PROCESS;
+ vt_mode.waitv = 0;
+ vt_mode.relsig = SIGUSR1;
+ vt_mode.acqsig = SIGUSR2;
+
+ if( -1 == ioctl( p_sys->i_tty, VT_SETMODE, &vt_mode ) )
+ {
+ msg_Err( p_vout, "cannot set terminal mode (%m)" );
+ sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
+ sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
+ tcsetattr(0, 0, &p_vout->p_sys->old_termios);
+ TextMode( p_sys->i_tty );
+ free( p_vout->p_sys );
+ return VLC_EGENERIC;
+ }
+ }
+
+ if( OpenDisplay( p_vout ) )