I want to write a program running 2 threads. While main thread busy doing its job, the other thread act as an interactive cmdline, reads user input, then print something to terminal. 

My code looks like this now:

```
#include <pthread.h>

//Needed for pthread
#ifndef _REENTRANT
#define _REENTRANT
#endif

#include "whatever_u_need.h"
bool g_isDone = false;

void* cmdMain( void* ) {
    static char* buf;
    buf = (char*)malloc( 257 );
    buf[256]=0;
    size_t size = 256;

    while(!g_isDone) {
        printf( "> " );
        getline( &buf, &size, stdin );
        if( buf[0] == 'q' ) { 
            g_isDone  =true;
            break;
        }
        //echo
        puts(buf);
    }
    free( buf );
    pthread_exit(NULL);
}

pthread_t g_cmd_thread;

int main() {
    pthread_create( &g_cmd_thread, NULL, cmdMain, NULL );
    while(1) {
        //non-interactive jobs
    }
    pthread_cancel( g_cmd_thread );

    return 0;
}

```

The problem is, when executing getline(), I hit ENTER, then the terminal moves 2 lines down.
Definitely both threads have recieved the "ENTER message". How can I turn off the terminal I/O for the main thread but keeping the other thread's command-line functionality?

I'm using Ubuntu with bash shell.