hush for non-mmu system

Denys Vlasenko vda.linux at googlemail.com
Tue Sep 2 18:45:10 UTC 2014


On Tue, Sep 2, 2014 at 6:21 PM, Waldemar Brodkorb <wbx at openadk.org> wrote:
>> This shows that signal handler fails to return properly.
>> Let's check whether it works with this simple program:
>>
>> #include <unistd.h>
>> #include <signal.h>
>> #include <sys/types.h>
>> #include <sys/wait.h>
>> static void sighandler(int sig)
>> {
>>         write(1, "SIGNAL\n", 7);
>> }
>> int main()
>> {
>>         int pid;
>>
>>         write(1, "VFORK1\n", 7);
>>         pid = vfork();
>>         if (pid == 0) {
>>                 write(1, "EXIT1\n", 6);
>>                 _exit(1);
>>         }
>>         wait(NULL);
>>         signal(SIGCHLD, sighandler);
>>         write(1, "VFORK2\n", 7);
>>         pid = vfork();
>>         if (pid == 0) {
>>                 write(1, "EXIT2\n", 6);
>>                 _exit(1);
>>         }
>>         wait(NULL);
>>         write(1, "EXIT\n", 5);
>>         return 0;
>> }
>>
>> On my machine, it works like this:
>> i.e. signal handler did not mess up the parent.
>>
>> What do you see?
>
> I see:
> /> /sighandler
> VFORK1
> EXIT1
> VFORK2
> EXIT2
> SIGNAL
> /> strace -f  /sighandler
> VFORK1
> EXIT1
> wait4(-1, NULL, 0, NULL)                = 44
> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=44,
> si_status=1, si_utime=0, si_stime=0} ---
> rt_sigaction(SIGCHLD, {0x41eae080, [CHLD], SA_RESTART}, {SIG_DFL,
> [], 0}, 8) = 0
> write(1, "VFORK2\n", 7VFORK2
> )                 = 7
> vfork(Process 45 attached
>  <unfinished ...>
> [pid    45] write(1, "EXIT2\n", 6EXIT2
> )      = 6
> [pid    45] _exit(1)                    = ?
> [pid    43] <... vfork resumed> )       = 45
> [pid    43] wait4(-1,  <unfinished ...>
> [pid    45] +++ exited with 1 +++
> <... wait4 resumed> NULL, 0, NULL)      = 45
> --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=45,
> si_status=1, si_utime=0, si_stime=0} ---
> write(1, "SIGNAL\n", 7SIGNAL
> )                 = 7
> sigreturn() (mask [HUP TRAP])           = 45
> rt_sigreturn()                          = 0
> --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
> +++ killed by SIGSEGV +++
> />


This proves that there is some problem with returns from signal handlers.
It may be in kernel or in uclibc.

Can you try compiling the example against a different libc?

Consider posting this example and its strace to linux kernel mailing list.


More information about the busybox mailing list