This is the mail archive of the glibc-bugs@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug linuxthreads/810] pthread_create() doesn't fail with EPERM


------- Additional Comments From nikolay dot zhuravlev at auriga dot ru  2005-03-30 14:24 -------
The corrected test case follows...


#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <limits.h>

#define PRIO 17

pthread_t tid;

void *
thread1( void *arg )
{
    pthread_exit(0);
    return 0;
}

int main(int argc, char *argv[])
{

    int err;
    int status;         /* used in pthread_join() */
    struct sched_param  params;
    pthread_attr_t attr;

    if (pthread_attr_init(&attr)) {
        printf("pthread_attr_init FAILED\n");
        exit(1);
    }

    if (pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED)) {
        printf("\npthread_attr_setinheritsched FAILED\n");
        (void) pthread_attr_destroy( &attr );
        exit(1);
    }

    if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO)) {
        printf("\npthread_attr_setschedpolicy FAILED\n");
        (void) pthread_attr_destroy( &attr );
        exit(1);
    }

    params.sched_priority = PRIO;
    if (pthread_attr_setschedparam(&attr, &params)) {
        printf("\npthread_attr_setschedparam FAILED\n");
        (void) pthread_attr_destroy( &attr );
        exit(1);
    }

    if ((err = pthread_create(&tid, &attr, &thread1, NULL)) != EPERM) {

        printf("TEST FAILED\n");

        if (err == 0 && pthread_join(tid, (void **)&status)) {
            printf("pthread_join FAILED\n");
            (void) pthread_cancel(tid);
        }
    } else {

        printf("TEST OK\n");

    }
    (void) pthread_attr_destroy( &attr );
    return(0);
}


-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=810

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]