I reduced the code to a more condensed version, and reproduced it with it, on another system:
#include <stdio.h>
#include <stdlib.h>
#include <threads.h>
#include <strings.h>
#include <time.h>
int thread_func(void *arg)
{
printf("Entering 2nd thread\n");
struct timespec sleeptime1;
sleeptime1.tv_sec = 5;
thrd_sleep(&sleeptime1,NULL);
printf("Second thread finished sleeping\n");
thrd_exit(thrd_success);
}
int main (int argc, char *argv[])
{
thrd_t secondthread;
if (thrd_create (&secondthread,thread_func,NULL) != thrd_success )
{
perror("Thread failed");
return 1;
}
thrd_detach(secondthread);
printf("Main goes on\n");
struct timespec sleeptime2;
sleeptime2.tv_sec = 10;
thrd_sleep(&sleeptime2,NULL);
printf("Main finished sleeping\n");
thrd_exit(thrd_success);
}
BTW: I am using Pelles C 7.00.355 (Win64) on Win7 64 bit Service Pack 1 (7601)