Sourceware Bugzilla – Attachment 5677 Details for
Bug 12683
Race conditions in pthread cancellation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Demonstration of problem 2
cancel_async.c (text/plain), 930 bytes, created by
Rich Felker
on 2011-04-18 22:34:44 UTC
(
hide
)
Description:
Demonstration of problem 2
Filename:
MIME Type:
Creator:
Rich Felker
Created:
2011-04-18 22:34:44 UTC
Size:
930 bytes
patch
obsolete
>#define _XOPEN_SOURCE 700 >#include <stdio.h> >#include <pthread.h> >#include <errno.h> >#include <signal.h> > >volatile int x; > >static void handler(int sig) >{ > for (;;) x++; >} > >static void bye(void *arg) >{ > printf("x=%d\n", x); >} > >static void *start(void *foo) >{ > sigset_t set; > sigemptyset(&set); > sigaddset(&set, SIGUSR1); > pthread_cleanup_push(bye, 0); > pthread_sigmask(SIG_UNBLOCK, &set, 0); > for (;;) sleep(1); > pthread_cleanup_pop(0); > return 0; >} > >int main() >{ > pthread_t t; > void *res; > struct sigaction sa = { 0 }; > sigemptyset(&sa.sa_mask); > sa.sa_handler = handler; > sa.sa_flags = SA_RESTART; > sigaction(SIGUSR1, &sa, 0); > sigaddset(&sa.sa_mask, SIGUSR1); > pthread_sigmask(SIG_BLOCK, &sa.sa_mask, 0); > > pthread_create(&t, 0, start, 0); > nanosleep(&(struct timespec){.tv_nsec=100000000},0); > kill(getpid(), SIGUSR1); > nanosleep(&(struct timespec){.tv_nsec=100000000},0); > pthread_cancel(t); > pthread_join(t, 0); > 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 12683
:
5676
| 5677