From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sun, 29 Jul 2001 17:28:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sun, 29 Jul 2001 17:28:44 -0400 Received: from mailout03.sul.t-online.com ([194.25.134.81]:47631 "EHLO mailout03.sul.t-online.de") by vger.kernel.org with ESMTP id ; Sun, 29 Jul 2001 17:28:26 -0400 Content-Type: text/plain; charset=US-ASCII From: oliver.kowalke@t-online.de (Oliver Kowalke) To: linux-kernel@vger.kernel.org Subject: sendto generates SIGSEGV Date: Sun, 29 Jul 2001 23:27:29 +0200 X-Mailer: KMail [version 1.2] MIME-Version: 1.0 Message-Id: <01072923272900.32616@p3x2lx> Content-Transfer-Encoding: 7BIT Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Original-Recipient: rfc822;linux-kernel-outgoing Hi, I've written an c++ class which wrappes a socket.. With function writen() you can write to an TCP and UDP socket ( TCP : pointer to stuct sockaddr == NULL; UDP : pointer to struct sockaddr != NULL). If I use this function with TCP sockets all works. If I call this function for an UDP socket it generates an SIGSEGV signal. What is wrong? with regards, Oliver ssize_t writen( const void * vptr, size_t n, struct sockaddr * to) { size_t nleft = n; ssize_t nwritten; const char *ptr = static_cast< const char * >( vptr); struct sigaction new_sa; struct sigaction old_sa; new_sa.sa_handler = SIG_IGN; ::sigemptyset( & new_sa.sa_mask); new_sa.sa_flags = 0; ::sigaction( SIGPIPE, & new_sa, & old_sa); while ( nleft > 0) { if ( ( nwritten = ::sendto( m_handle, ptr, nleft, 0, to, sizeof * to) )<=0) { if ( errno == EINTR) nwritten = 0; // and call sendto() again else if ( errno == EPIPE) { ::sigaction( SIGPIPE, & old_sa, 0); return -1; // write to sock with no readers (peer has the sock closed) } else { ::sigaction( SIGPIPE, & old_sa, 0); throw; // error } } nleft -= nwritten; ptr += nwritten; } ::sigaction( SIGPIPE, & old_sa, 0); // set to its previous action return n; } here the output of the generated core file: Core was generated by 'lt-ogx 192.168.1.3 10000'. Program terminated with signal 11, Segmentation fault. rw_common (): write: Success. warning: unable to get global thread event mask [New Thread 1024 (LWP 32350)] rw_common (): write: Success. warning: stop_or_attach_thread: generic error #0 0x0 in ?? ()