Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 23758 - exit in libpthread is broken.
exit in libpthread is broken.
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
All Linux
high Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2001-01-10 21:33 EST by Need Real Name
Modified: 2016-11-24 10:19 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-01-12 08:22:14 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2001-01-10 21:33:02 EST
The new libpthread records the pthread_exit_process() exit handler with
cxa_atexit() instead of on_exit() when possible.
The glibc exit() does not include the exit code when calling this flavor 
of exit handler.
As a side effect, a multithreaded program will always terminate with the
exit code 0 if the thread that does exit() is not the main thread.


How to reproduce
$ cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

do_exit(void* dummy)
     * Just call exit with code 2.
    printf("exit thread does exit\n");

    int       ret;
    pthread_t th_exit;

     * Create a default pthread to handle the 
     * process exit.
    ret = pthread_create(&th_exit, NULL, do_exit, NULL);
    if (ret != 0) {
	perror("pthread_create failed");
     * Just loop indefinitely waiting for the
     * process to exit.
    printf("main thread loops\n");
    return 0;

$./test; echo $?
0 <- Should actually be 2
Comment 1 Jakub Jelinek 2001-01-12 08:22:10 EST
My patch for this was accepted into CVS glibc, it will also appear once next
glibc rpms are cut.
Comment 2 Jakub Jelinek 2001-01-23 05:12:37 EST
Fixed in glibc-2.2.1-2 in rawhide.

Note You need to log in before you can comment on or make changes to this bug.