BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005304 [BusyBox] Other minor always 10-08-08 08:58 10-27-08 07:35
Reporter ianw View Status public  
Assigned To BusyBox
Priority normal Resolution fixed  
Status closed   Product Version svn
Summary 0005304: Busybox ash ignoring SIGINT when it shouldn't be
Description Hi,

As per the attached program; the busybox shell will never register the SIGINT and die; it remains in a tight loop printing out it's PID.
Additional Information #!/bin/sh

IsProcessRunning()
{
   kill -0 ${1} >/dev/null 2>&1
}

main()
{
   local PID=

   /path/to/busybox sh -c 'while [ 1 ] ; do echo $$ ; done' &

   PID=${!}

   while IsProcessRunning ${PID} ; do
      kill -INT ${PID}
   done
}

main "${@}"
Attached Files  test.sh [^] (247 bytes) 10-08-08 08:58
 8.patch [^] (881 bytes) 10-27-08 07:33

- Relationships

- Notes
(0014344)
vda
10-27-08 06:45
edited on: 10-27-08 06:52

Your example is racy. Most of the time kill -INT manages to kill off child shell before it manages to disable SIGINT. This is a fixed example:

#!/bin/sh
sh -c 'echo Child: $$; while sleep 1; do echo -n c; done' &
PID=$!
sleep 0.1
while kill -0 $PID >/dev/null 2>&1; do
    sleep 0.5
    kill -INT $PID >/dev/null 2>&1
    echo -n $?
done

Because of sleep 0.1, now child has time to set SIGINT as it wants it, and kill -INT does not kill child anymore. This example works the same with bash and busybox ash: it shows child's PID and then "c00c00c00c00..." - child ignores SIGINT. Looks like bash manpage talks about it here:

       Non-builtin commands run by bash have signal handlers set to the values
       inherited by the shell from its parent. When job control is not in
       effect, asynchronous commands ignore SIGINT and SIGQUIT in addition to
       these inherited handlers.

However, this example does not work with busybox ash:

#!/bin/sh
sh -c 'echo Child: $$; while sleep 1; do echo -n c; done' &
PID=$!
sleep 0.1
while kill -0 $PID >/dev/null 2>&1; do
# sleep 0.5
    kill -INT $PID >/dev/null 2>&1 || echo Killed
done

If I kill the child from another console, parent gets SIGCHLD, but does *not* wait() for exited child. This is a bug. Child remains a zombie, "kill $PID" still works, parent loops forever. With bash, it detects child's death and exits.

 
(0014354)
vda
10-27-08 07:35

Fixed in rev. 23820. Thanks.
Patch is attached, please reopen this bug if you find that the problem is not fixed by it.
 

- Issue History
Date Modified Username Field Change
10-08-08 08:58 ianw New Issue
10-08-08 08:58 ianw Status new => assigned
10-08-08 08:58 ianw Assigned To  => BusyBox
10-08-08 08:58 ianw File Added: test.sh
10-27-08 06:45 vda Note Added: 0014344
10-27-08 06:45 vda Note Edited: 0014344
10-27-08 06:46 vda Note Edited: 0014344
10-27-08 06:47 vda Note Edited: 0014344
10-27-08 06:48 vda Note Edited: 0014344
10-27-08 06:49 vda Note Edited: 0014344
10-27-08 06:52 vda Note Edited: 0014344
10-27-08 07:33 vda File Added: 8.patch
10-27-08 07:35 vda Status assigned => closed
10-27-08 07:35 vda Note Added: 0014354
10-27-08 07:35 vda Resolution open => fixed


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker