This is the mail archive of the glibc-bugs@sourceware.org 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 nptl/4939] New: setpgid fails from a thread other than main


I see no reason why the following call to setpgid would fail:

#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <stdio.h>

void *thread_body(void *arg) {
   pid_t pid;
   int status;
   (void)arg;
   pid = fork();
   if (pid == 0) {
      sleep(1);
      exit(0);
   }
   if (setpgid(pid, 0) == -1)
      perror("setpgid");
   else
      printf("ok\n");
   return NULL;
}

int main(void) {
   pthread_t th;
   printf("From the main thread\n");
   thread_body(NULL);
   printf("From another thread\n");
   pthread_create(&th, NULL, thread_body, NULL);
   pthread_join(th, NULL);
   return 0;
}

Actual result:

>From the main thread
ok
>From another thread
setpgid: No such process

Expected result:

>From the main thread
ok
>From another thread
ok

-- 
           Summary: setpgid fails from a thread other than main
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: qrczak at knm dot org dot pl
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=4939

------- 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]