[PATCH] display mask on enter to sigreturn, not exit

Dmitry V. Levin ldv at altlinux.org
Tue Jan 10 20:19:48 UTC 2012


Hi,

On Mon, Jan 09, 2012 at 01:49:10PM +0100, Denys Vlasenko wrote:
> sys_sigreturn() performs ugly manipulations in order to show
> the signal mask which is restored by this syscall: on syscall entry,
> fetches it from the stack, saves it in tcp->u_arg[]
> (where it used to overflow this array - fixed sometime ago),
> then retrieves the mask and displays it on syscall exit.
> 
> Apparently, the motivation is to make it slightly more obvious
> to user that signal mask is restored only when this syscall returns.
> IMO, this hardly justifies the necessary hacks. It is much easier
> to display the mask at the point when we fetch it - on syscall entry.

I agree on this point, decoding on entering syscall results to much more
clear code.

> While at it, I made it so that we do display returned value/errno.
> I see no point in hiding it and showing uninformative "= ?" instead.

Is there any actual difference?  Is there any case when sigreturn() may
"return" something different from EINTR?

> Example of pause() being interrupted by ALRM which has installed handler
> which re-arms ALRM:
> Before the patch:
> 
> rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
> --- {si_signo=SIGALRM, si_code=SI_KERNEL} (Alarm clock) ---
> rt_sigaction(SIGALRM, {0x807b18a, [ALRM], SA_RESTORER|SA_RESTART, 0x80486e3}, {0x807b18a, [ALRM], SA_RESTORER|SA_RESTART, 0x80486e3}, 8) = 0
> alarm(1)                                = 0
> sigreturn()                             = ? (mask now [INT])
> 
> After:
> 
> rt_sigsuspend([INT])                    = ? ERESTARTNOHAND (To be restarted)
> --- {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=134513920, ptr=0x8048500}} (Alarm clock) ---
> rt_sigaction(SIGALRM, {0x807b18a, [ALRM], SA_RESTORER|SA_RESTART, 0x80486e3}, {0x807b18a, [ALRM], SA_RESTORER|SA_RESTART, 0x80486e3}, 8) = 0
> alarm(1)                                = 0
> sigreturn() (mask now [INT])            = -1 EINTR (Interrupted system call)
> 
> An open question is how exactly to display the mask.
> "mask now"? "[sig]mask on stack?" Other ideas?

Well, the new output is a bit odd.  Something meaningful between
")" and "=" is not what a strace user is used to deal with.
I'd be glad if somebody would come up with a better idea how to
display this.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20120111/591d8fdf/attachment.bin>


More information about the Strace-devel mailing list