Operating System - Linux
1752795 Members
6164 Online
108789 Solutions
New Discussion юеВ

Re: pthread cancel on HPUX

 
Manish_33
Advisor

pthread cancel on HPUX

Hello friends,

I am having some confusions regarding use of pthread_cancel and
pthread_cleanup_push. Even though i have made my thread as
cancellation enabled and asynchronous cancellation enabled.....it
doesn't seem to catch them unless a cancellation point is
reached.......Could someone throw some light on this.......Below is my
sample program...

#include
#include
#include

pthread_t stid;

void hndlr(void *a){
printf("I am in pthread handler\n");
return ;
}

void *sstart(void *tid){
int oldstate;

fprintf(stderr,"Starting second child tid=%d\n",pthread_self());

pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,&oldstate); /*Enable
cancellation again*/
fprintf(stderr,"Enabled cancelling, old state was %d\n",oldstate);
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,&oldstate);
/*Enable asynchronous cancellation*/
fprintf(stderr,"Enabled asynchronous cancelling, old state was
%d\n",oldstate);

pthread_cleanup_push(hndlr,NULL);
printf("\nI have pushed a function\n");
pthread_cancel(pthread_self());
printf("\nThis is a cancellation point.\n");
pthread_cleanup_pop(0);
return NULL ;
}

int main(){
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&stid,&attr,sstart,NULL);
pthread_join(stid,NULL);
return 0;
}



As you can see if i comment out the printf statement..."This is a
cancellation point" the handler will not be called.....Why is that i
need an explicit cancelation point ??
2 REPLIES 2
Dennis Handly
Acclaimed Contributor

Re: pthread cancel on HPUX

It appears you have moved this discussion to:
HPUX-DEVTOOLS: Cancellation points in HP
Manish_33
Advisor

Re: pthread cancel on HPUX

This is a bug in HP and they have promised to release an official patch for this. Till now no official patch is available.