RE: Re: What is the best way to interrupt a
Hmm that did not work. I think I did it right:
#define SIGSTOP SIGUSR1
Reader:
struct sigaction sa;
& nbsp; sigemptyset(&sa.sa_mask);
sa.sa_handler = sig_handler;
sa.sa_flags = 0;
int status = sigaction(SIGSTOP, &sa, NULL);
sio_fd = open("/dev/ttyS1", O_RDONLY);.
.
.
uint8_t c;
while (_tcb ->theventset == noEvents ) {
if (sizeof(c) == read(sio_fd,&c,sizeof(c))) {
yada
}
}
Task stop
uint32_t flags = irqsave();
& nbsp; _tcb->theventset |= ExitRequest;
irqrestore(flags);
pthread_kill(_tcb->thread,SIGSTOP);
  ;
…. The issue is was in uart_read it never returned. I looked at it was waiting one a semaphore in a loop. And the loop did not exit
David
From: nuttx-hHKSG33TihhbjbujkaE4pw@public.gmane.org [mailto:nuttx-hHKSG33TihhbjbujkaE4pw@public.gmane.org] On Behalf Of Gregory N
Sent: Friday, December 02, 2011 5:08 PM
To: nuttx-hHKSG33TihhbjbujkaE4pw@public.gmane.org
Subject: [nuttx] Re: What is the best way to interrupt a
> What is the best way to interrupt a pthread in a blocking read() of /dev/ttyS1?
>
> I want the thread to break out of it's loop and close the files and queues it has open.
A couple of ways come to mind. But based on what you describe, the best way might be to just send a signal to the thread that is waiting on the blo
cking read(). read() will wake-up and return an error (-1) with the errno set to EINTR. That is standard behavior.
Greg
RSS Feed