How can a program be stopped from a non-main thread?
I'm creating a new thread.
/* Listen for user commands in new thread */
pthread_t tid;
pthread_create(&tid, NULL, &commands, NULL);
I want to stop the program if the user types exit.
/* Listen for user input */
void *commands(void *arg)
{
    char command[100]; 
    while(1)
    {
        printf("Type 'exit' to stop program\n");
        fgets (command, 100, stdin); 
        if(strcmp(command, "exit") == 0) {
            // TODO exit
        }
    }
}
I tried calling exit(0) from the commands method but this did nothing.
 
    