File tree Expand file tree Collapse file tree 1 file changed +31
-12
lines changed
Expand file tree Collapse file tree 1 file changed +31
-12
lines changed Original file line number Diff line number Diff line change 2626# include <unistd.h>
2727#endif
2828
29+ #include <pthread.h>
2930#include <stdbool.h>
3031#include <stdint.h>
3132#include <stdio.h>
@@ -322,21 +323,39 @@ jalv_frontend_select_plugin(Jalv* jalv)
322323 return NULL ;
323324}
324325
326+ void * cli_thread (void * arg ) {
327+ while (1 ) {
328+ char line [1024 ];
329+ printf ("> " );
330+ if (fgets (line , sizeof (line ), stdin )) {
331+ jalv_process_command ((Jalv * ) arg , line );
332+ } else {
333+ break ;
334+ }
335+ }
336+ return NULL ;
337+ }
338+
339+ pthread_t init_cli_thread (Jalv * jalv ) {
340+ pthread_t tid ;
341+ int err = pthread_create (& tid , NULL , & cli_thread , jalv );
342+ if (err != 0 ) {
343+ printf ("Can't create CLI thread :[%s]" , strerror (err ));
344+ return 0 ;
345+ } else {
346+ printf ("CLI thread created successfully\n" );
347+ return tid ;
348+ }
349+ }
350+
325351int
326352jalv_frontend_open (Jalv * jalv )
327353{
328- if (!jalv_run_custom_ui (jalv ) && !jalv -> opts .non_interactive ) {
329- // Primitive command prompt for setting control values
330- while (zix_sem_try_wait (& jalv -> done )) {
331- char line [1024 ];
332- printf ("> " );
333- if (fgets (line , sizeof (line ), stdin )) {
334- jalv_process_command (jalv , line );
335- } else {
336- break ;
337- }
338- }
339- } else {
354+ if (!jalv -> opts .non_interactive ) {
355+ init_cli_thread (jalv );
356+ }
357+
358+ if (!jalv_run_custom_ui (jalv )) {
340359 zix_sem_wait (& jalv -> done );
341360 }
342361
You can’t perform that action at this time.
0 commit comments