Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 May 2013 12:10:01 GMT
From:      Jilles Tjoelker <jilles@stack.nl>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/178664: truss(1) may kill process
Message-ID:  <201305191210.r4JCA1hm090229@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/178664; it has been noted by GNATS.

From: Jilles Tjoelker <jilles@stack.nl>
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201305191210.r4JCA1hm090229>