Failed to make error EINTR with pthread_kill, but succeed with kill
To do unit test, I want to make sem_wait get error EINTR.
I've written a program below: Code:
#include <stdio.h> Code:
sig_handler_drp:19: SIGUSR1 received the program will get stuck by sem_wait. Why I can't make error EINTR with pthread_kill? |
Why did you expect you could?
Anyways, change this: Code:
old: PRINTF("ERROR! sem_wait\n"); |
Quote:
Maybe I was wrong. :) Is that possible with pthread_kill()? Wow, using strerror() is amazing! Thanks! |
Did you read the man page for pthread_kill? You are sending a signal to the thread that is calling pthread_kill and then exiting. While signal handlers are shared pthread_kill only signals the thread whose id is passed. In other words your program is behaving the way it should.
Here is a signal going both ways -all error checking absent and not ready for prime time: Code:
#include <pthread.h> |
Quote:
Thanks for your reply! Now I've changed the 4th parameter of pthread_create to '&tid_main' which value is given by running pthread_self() in function main, and it works fine. My program is changed to: Code:
#include <stdio.h> |
All times are GMT -5. The time now is 10:58 AM. |