From owner-freebsd-threads@FreeBSD.ORG Fri Oct 7 16:26:24 2005 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EFB2416A41F; Fri, 7 Oct 2005 16:26:23 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7392143D45; Fri, 7 Oct 2005 16:26:23 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.5/8.13.5/NETPLEX) with ESMTP id j97GQMdj011952; Fri, 7 Oct 2005 12:26:22 -0400 (EDT) Date: Fri, 7 Oct 2005 12:26:22 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Robert Watson In-Reply-To: <20051006121233.D84936@fledge.watson.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; FORMAT=flowed Content-ID: X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: threads@freebsd.org Subject: Re: SIGINFO interrupts connect() with libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Oct 2005 16:26:24 -0000 On Thu, 6 Oct 2005, Robert Watson wrote: > > I was writing test tools yesterday, and was a bit surprised to find that > hitting ctrl-T interrupts connect() for applications linked against > libpthread(). I wrote a simple test tool and found that this is not the > case for any of the other thread libraries (which seems correct to me). > Test tool attached: This isn't a problem with libpthread. If you install a signal handler for SIGINFO in your application with sa_flags = SA_RESTART, it gets interrupted even when just linked with libc. -- DE /*- * Copyright (c) 2005 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include void sighandler(int sig) { } int main(int argc, char *argv[]) { struct sockaddr_in sin; struct sigaction act; int sock; if (argc != 3) errx(-1, "usage: connect [ip] [port]"); sigfillset(&act.sa_mask); act.sa_flags = SA_RESTART; act.sa_handler = sighandler; sigaction(SIGINFO, &act, NULL); bzero(&sin, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr(argv[1]); sin.sin_port = htons(atoi(argv[2])); sock = socket(PF_INET, SOCK_STREAM, 0); if (sock < 0) err(-1, "socket(PF_INET, SOCK_STREAM, 0)"); printf("Connecting to %s:%d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); if (connect(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) err(-1, "connect(%s %d)", inet_ntoa(sin.sin_addr), htons(sin.sin_port)); printf("Connected\n"); return (0); }