@@ -48,7 +48,6 @@ uint16_t alt_launcher_fb_terminal_key(uint32_t mask, bool osd_button)
4848static pid_t s_pid = 0 ;
4949static int s_crash_count = 0 ;
5050static unsigned long s_respawn_timer = 0 ;
51- static unsigned long s_tty_deadline = 0 ;
5251static bool s_gave_up = false ;
5352static bool s_init_pending = false ;
5453static const int s_vt = 2 ;
@@ -110,6 +109,16 @@ static bool launcher_tty_ready(pid_t pid)
110109 return false ;
111110}
112111
112+ static void wait_launcher_tty_ready (pid_t pid)
113+ {
114+ for (int i = 0 ; i < 100 ; i++)
115+ {
116+ if (launcher_tty_ready (pid))
117+ return ;
118+ usleep (10000 );
119+ }
120+ }
121+
113122static void return_to_normal_mode (void )
114123{
115124 user_io_osd_key_enable (1 );
@@ -125,7 +134,6 @@ static void reset_launcher_state(void)
125134{
126135 s_pid = 0 ;
127136 s_respawn_timer = 0 ;
128- s_tty_deadline = 0 ;
129137 s_crash_count = 0 ;
130138 s_gave_up = false ;
131139 s_init_pending = false ;
@@ -180,13 +188,7 @@ static void spawn(void)
180188 _exit (1 );
181189 }
182190
183- s_tty_deadline = GetTimer (1000 );
184- if (!s_tty_deadline) s_tty_deadline = 1 ;
185- }
186-
187- static void finalize_spawn (void )
188- {
189- s_tty_deadline = 0 ;
191+ wait_launcher_tty_ready (s_pid);
190192 video_chvt (s_vt);
191193 video_fb_enable (1 );
192194}
@@ -213,7 +215,6 @@ void alt_launcher_poll(void)
213215 if (waitpid (s_pid, &status, WNOHANG ) == s_pid)
214216 {
215217 s_pid = 0 ;
216- s_tty_deadline = 0 ;
217218 user_io_osd_key_enable (1 );
218219 bool exited = WIFEXITED (status);
219220 int exit_status = exited ? WEXITSTATUS (status) : 0 ;
@@ -236,11 +237,7 @@ void alt_launcher_poll(void)
236237 s_crash_count = 0 ;
237238 s_respawn_timer = GetTimer (1000 );
238239 if (!s_respawn_timer) s_respawn_timer = 1 ;
239- return ;
240240 }
241-
242- if (s_tty_deadline && (launcher_tty_ready (s_pid) || CheckTimer (s_tty_deadline)))
243- finalize_spawn ();
244241 return ;
245242 }
246243
0 commit comments