From owner-freebsd-bugs@FreeBSD.ORG Sun May 19 12:10:02 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6CAE0924 for ; Sun, 19 May 2013 12:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 5A6DB6DE for ; Sun, 19 May 2013 12:10:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r4JCA1Gj090230 for ; Sun, 19 May 2013 12:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r4JCA1hm090229; Sun, 19 May 2013 12:10:01 GMT (envelope-from gnats) Date: Sun, 19 May 2013 12:10:01 GMT Message-Id: <201305191210.r4JCA1hm090229@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Jilles Tjoelker Subject: Re: bin/178664: truss(1) may kill process X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 May 2013 12:10:02 -0000 The following reply was made to PR bin/178664; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, kwiat3k@panic.pl Cc: Subject: Re: bin/178664: truss(1) may kill process Date: Sun, 19 May 2013 14:09:32 +0200 In PR bin/178664, you wrote: > [attaching truss(1) may terminate sleep(1) early] What actually happens is that the nanosleep(2) system call fails with [EINTR] immediately when the debugger (ptrace(2)) attaches. You can verify this using ktrace(1). This is really a longstanding known bug, although I don't know where it is documented. It is longstanding because it is very hard to fix. The kernel wants threads to return to the kernel-userspace boundary when a debugger attaches, and this causes the state of the in-progress system call to be lost. The effect is much like a signal with SA_RESTART set. If you care about sleep(1) itself, that is easy to fix. It already continues the sleep when nanosleep(2) was interrupted by SIGINFO; this can be extended to any [EINTR] error. A workaround is to use ktrace(1) instead of truss(1) or strace(1) from ports. ktrace(1) generally affects the traced program much less. -- Jilles Tjoelker