Re: Signals and threads
- From: loic-dev@xxxxxxx
- Date: 25 Nov 2006 09:09:36 -0800
Hello Thomas,
Finally, how do you send the SIGUSR1 to your threadA?
its pthread_kill(threadId,SIGUSR1);
It is difficult for us to help you, as we (obviously) do not have the
particular version "libpthread" that you have...
Could you please compile the program below and send us the
corresponding trace file:
$ strace -f -o trace.txt binaryName
Thanks,
Loic.
/*
compile: gcc -pthread try.c -o try
trace : strace -f -o trace.txt ./try
*/
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
void
handlerOne(int signo)
{
write(STDOUT_FILENO, "1", 1);
}
void
handlerTwo(int signo)
{
write(STDOUT_FILENO, "2", 1);
}
typedef void (*sighand_t)(int);
void*
thread(void* arg)
{
struct sigaction act;
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
act.sa_handler = (sighand_t) arg;
act.sa_mask = set;
act.sa_flags = 0;
sigaction(SIGUSR1, &act, 0);
for (;;) {
sleep(1000);
}
return 0;
}
int main()
{
pthread_t tid1, tid2;
int rc = pthread_create(&tid1, 0, thread, (void*) handlerOne );
assert (rc==0 && "pthread_create");
sleep(1);
rc = pthread_create(&tid2, 0, thread, (void*) handlerTwo);
assert (rc==0 && "pthread_create");
sleep(1);
pthread_kill(tid1, SIGUSR1);
sleep(1);
pthread_kill(tid2, SIGUSR1);
sleep(1);
return 0;
}
.
- References:
- Signals and threads
- From: shibu-kundara
- Re: Signals and threads
- From: loic-dev
- Re: Signals and threads
- From: shibu-kundara
- Re: Signals and threads
- From: loic-dev
- Re: Signals and threads
- From: shibu-kundara
- Signals and threads
- Prev by Date: Re: Blocking read() from a USB->Serial adapter.
- Next by Date: Re: Signals and threads
- Previous by thread: Re: Signals and threads
- Next by thread: Blocking read() from a USB->Serial adapter.
- Index(es):
Relevant Pages
|