You aren't allocating memory for global_variable
, so fgets
tries to write at a random position in memory, leading to the OS detect memory violation and stopping the process by sending SIGSEGV that causes segmentation fault.
Change the your main to something like this:
int main () {
pthread_t t_m, t1, t2, t3;
global_variable = malloc(sizeof(char)*999);
//const char *m1 = "Thread 1", *m2 = "Thread 1", *m3 = "Thread 3";
...more code...
printf("Global Variable: %s", global_variable);
free(global_variable);