On Monday 12 September 2011, Paul Eggert wrote: > On 09/12/11 09:19, Stefano Lattarini wrote: > > > This example might show the problem more clearly: > > Yes, thanks, that does clarify matters, and my guesses seem > incorrect. It does seem that ksh's behavior (in your last > example, anyway) violates POSIX > <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_12>. > Thanks for the reference.
Now some updates: the "default" Korn Shell on Debian GNU/Linux (package `ksh', version `93u-1') seems to exhibit the same issue: $ ksh -c "perl -e 'kill 2, \$\$'; :"; echo $? 130 And if I'm not reading the strace output wrong, this is due to the fact that the Debian korn shell is apparently killing itself (yikes!) with the same signal that killed the child process: $ strace ksh -c "perl -e 'kill 2, \$\$'; :" ... getpid() = 15108 ... lstat64("/usr/bin/perl", {st_mode=S_IFREG|0755, st_size=1437872, ...}) = 0 rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT PIPE], [], 8) = 0 vfork() = 15109 --- SIGCHLD (Child exited) @ 0 (0) --- sigreturn() = ? (mask now [HUP INT QUIT PIPE]) rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 waitpid(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGINT}], WNOHANG|WSTOPPED|WCONTINUED) = 15109 waitpid(-1, 0xbfa0270c, WNOHANG|WSTOPPED|WCONTINUED) = -1 ECHILD (No child processes) rt_sigaction(SIGCHLD, {0x806e390, [], SA_INTERRUPT}, {0x806e390, [], SA_INTERRUPT}, 8) = 0 rt_sigaction(SIGINT, {0x80603b0, [], SA_INTERRUPT}, {SIG_DFL, [], 0}, 8) = 0 ioctl(2, TIOCGPGRP, [15107]) = 0 rt_sigaction(SIGINT, {0x80603b0, [], SA_INTERRUPT}, {0x80603b0, [], SA_INTERRUPT}, 8) = 0 getrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=RLIM_INFINITY}) = 0 setrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=RLIM_INFINITY}) = 0 rt_sigaction(SIGINT, {SIG_DFL, [], SA_INTERRUPT}, {0x80603b0, [], SA_INTERRUPT}, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [INT], NULL, 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [INT], NULL, 8) = 0 kill(15108, SIGINT) = 0 --- SIGINT (Interrupt) @ 0 (0) --- +++ killed by SIGINT +++ The truss output on Solaris is less clear (for me at least, I'm not used to it), and I'm not at all sure that the issue there is due to the same dynamics; more digging needed. Regards, Stefano