NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/46584: /proc/[pid]/task doesn't work



>Number:         46584
>Category:       kern
>Synopsis:       /proc/[pid]/task doesn't work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 11 08:05:00 +0000 2012
>Originator:     Yui NARUSE
>Release:        6.99.7
>Organization:
>Environment:
NetBSD kelvena.airemix.net 6.99.7 NetBSD 6.99.7 (GENERIC) #2: Thu May 17 
14:42:34 JST 2012  
naruse%kelvena.airemix.net@localhost:/usr/obj/sys/arch/amd64/compile/GENERIC 
amd64
>Description:
Recently NetBSD-current has /proc/[pid]/task but attached program doesn't work.
It only show main thread, doesn't show sub threads.
It correctly works on at least Ubuntu 10.04 amd64.

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
void *dummy(void *p) {
    sleep(100);
    return NULL;
}
int main(void) {
    int i;
    DIR *dirp;
    struct dirent *dp;
    pthread_t *thread = malloc(sizeof(pthread_t));
    if (pthread_create(thread, NULL, dummy, &i)) {
        perror("pthread_create");
        abort();
    }

    dirp = opendir("/proc/self/task");
    while (dp = readdir(dirp)) {
        printf("%s\n", dp->d_name);
    }
    return 0;
}
>How-To-Repeat:
% cat proc.c
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
void *dummy(void *p) {
    sleep(100);
    return NULL;
}
int main(void) {
    int i;
    DIR *dirp;
    struct dirent *dp;
    pthread_t *thread = malloc(sizeof(pthread_t));
    if (pthread_create(thread, NULL, dummy, &i)) {
        perror("pthread_create");
        abort();
    }

    dirp = opendir("/proc/self/task");
    while (dp = readdir(dirp)) {
        printf("%s\n", dp->d_name);
    }
    return 0;
}
% cc -pthread proc.c&&./a.out
.
..
22667
>Fix:



Home | Main Index | Thread Index | Old Index