From owner-freebsd-threads@FreeBSD.ORG Wed Aug 18 05:32:40 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FB641065672 for ; Wed, 18 Aug 2010 05:32:40 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 496CB8FC18; Wed, 18 Aug 2010 05:32:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o7I5Wcga004422; Wed, 18 Aug 2010 05:32:39 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4C6BE0F7.10207@freebsd.org> Date: Wed, 18 Aug 2010 13:32:39 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Kostik Belousov References: <4C642E9B.8000300@freebsd.org> <20100812093353.GS2396@deviant.kiev.zoral.com.ua> <4C650D0F.9060905@freebsd.org> <4C650F27.1000305@freebsd.org> <20100813141402.GW2396@deviant.kiev.zoral.com.ua> <4C65E0FE.2030803@freebsd.org> <20100814144715.GB2396@deviant.kiev.zoral.com.ua> <4C6926D0.2020909@freebsd.org> <20100816082022.GO2396@deviant.kiev.zoral.com.ua> <4C696A96.7020709@freebsd.org> <20100816104303.GP2396@deviant.kiev.zoral.com.ua> <4C6AA092.40708@freebsd.org> In-Reply-To: <4C6AA092.40708@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: PTHREAD_CANCEL_DEFERRED X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2010 05:32:40 -0000 David Xu wrote: > My idea is to always let close() syscall run, until it will be > blocked by lower layer, e.g tty or socket layer, as manual of close() > said it always release the file descriptor despite whether > it returns EINTR or EWOULDBLOCK, when it is going to sleep, > a flag will cause it to abort the sleep. > if the thread does not found the flag at that time, > a latter signal SIGCANCEL sent by pthread_cancel will unblock it, > this is how signal works. > I have worked out a patch: http://people.freebsd.org/~davidxu/patch/thread_cancel.patch