Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 83204 Details for
Bug 127698
sys-libs/glibc: deadlock within stdio when using GCC 4.1.0 builtin functions
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
test-cancel.c
A1vrhw37.txt (text/plain), 1.89 KB, created by
Diego Elio Pettenò (RETIRED)
on 2006-03-26 18:10:18 UTC
(
hide
)
Description:
test-cancel.c
Filename:
MIME Type:
Creator:
Diego Elio Pettenò (RETIRED)
Created:
2006-03-26 18:10:18 UTC
Size:
1.89 KB
patch
obsolete
>#define _MULTI_THREADED >#include <pthread.h> >#include <stdio.h> >#include <stdlib.h> > >#define checkResults(...) > >void cleanupHandler(void *parm) { > printf("Inside cancelation cleanup handler\n"); >} > >void *threadfunc(void *parm) >{ > unsigned int i=0; > int rc=0, oldState=0; > printf("Entered secondary thread\n"); > pthread_cleanup_push(cleanupHandler, NULL); > rc = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState); > checkResults("pthread_setcancelstate()\n", rc); > /* Allow cancel to be pending on this thread */ > sleep(2); > while (1) { > printf("Secondary thread is now looping\n"); > ++i; > sleep(1); > /* pthread_testcancel() has no effect until cancelability is enabled.*/ > /* At that time, a call to pthread_testcancel() should result in the */ > /* pending cancel being acted upon */ > pthread_testcancel(); > if (i == 5) { > printf("Cancel state set to ENABLE\n"); > rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,&oldState); > checkResults("pthread_setcancelstate(2)\n", rc); > /* Now, cancellation points will allow pending cancels > to get through to this thread */ > } > } /* infinite */ > pthread_cleanup_pop(0); > return NULL; >} > >int main(int argc, char **argv) >{ > pthread_t thread; > int rc=0; > void *status=NULL; > > printf("Enter Testcase - %s\n", argv[0]); > > /* Create a thread using default attributes */ > printf("Create thread using the NULL attributes\n"); > rc = pthread_create(&thread, NULL, threadfunc, NULL); > checkResults("pthread_create(NULL)\n", rc); > > sleep(1); > printf("Cancel the thread\n"); > rc = pthread_cancel(thread); > checkResults("pthread_cancel()\n", rc); > > rc = pthread_join(thread, &status); > if (status != PTHREAD_CANCELED) { > printf("Thread returned unexpected result!\n"); > exit(1); > } > printf("Main completed\n"); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 127698
: 83204