Problem delivering signals while blocked in recvfrom
Hi,
As per the subject, I have a single threaded process blocked collecting
UDP packets in recvfrom and I'm attempting to send it SIGHUP. No matter
what I do I get a segfault within the libc6. I've tried both the GNU
and BSD styles of signal handling, and within those have set flags for
both "fail the recvfrom" and "resume it", to no avail.
There's not a lot of complication involved in the crash:
GNU gdb 6.1-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-linux"...Using host libthread_db
library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /home/davep/pscope/tcom/flowlogd/flowlogd/flowlogd
Program received signal SIGHUP, Hangup.
0x4039c276 in recvfrom () from /lib/libc.so.6
There's a simple test case too. Compile and run this (c++), then send
it a SIGHUP. I know I've not put a handler in at all yet, it doesn't
need it in order to demonstrate the crash.
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h> //for bzero
#include <signal.h>
int main (int argc, char * const argv[])
{
//create and bind
int sockfd=socket(AF_INET,SOCK_DGRAM,0);
sockaddr_in servaddr;
bzero(&servaddr,sizeof(sockaddr_in));
servaddr.sin_family=AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
servaddr.sin_port=htons(1234);
bind(sockfd,(sockaddr*)&servaddr,sizeof(sockaddr_in));
//get a packet
char packet[8192];
sockaddr_in cliaddr;
socklen_t fromlen=sizeof(sockaddr_in);
recvfrom(sockfd,packet,8191,0,(sockaddr*)&cliaddr,&fromlen);
printf("Would be nice if recvfrom returned, eh?\n");
};
Am I missing something here? Any ideas what I can do?
Regards,
David Preece
Reply to: