pthreads recursively calling system command and segfault appears

Posted by jess on Stack Overflow See other posts from Stack Overflow or by jess
Published on 2012-11-22T10:57:52Z Indexed on 2012/11/22 10:59 UTC
Read the original article Hit count: 150

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about linux

Related posts about pthreads