pthreads recursively calling system command and segfault appears
- by jess
I have a code base where i am creating 8 threads and each thread just calls system command to display date in a continuous cycle, as shown below:
void *
system_thread(void *arg)
{
        int     cpu = (int)arg;
    printf("thread : start %d\n", cpu);
    for (;;) {
            //      date ã³ãã³ãã®å®è¡
            if (mode == 0) {
                    system("date");
            } else {
                    f_hfp_nlc_Fsystem("date");
            }
    }
    sleep(timerval);
    return NULL;
}
This application segfaults after running for 2-3 seconds, due to following 2 reasons:
1. read access, where the address is out of VM area
2. write acces, where it does not of write permission and its trying to modify some structure.