Discussion:
Problem with SIGINT in ash
Sergio
2008-12-15 17:33:26 UTC
Permalink
Hello list,

I found that a shell script like this:

#!/bin/ash
while true
do
echo Kill me
sleep 1
done

is not killed by a SIGINT (ctrl+c), instead it duplicates in another instance.
A SIGTERM signal correctly kills the script.

I have take a look to ash.c, probably there is something in onsig() and/or
raise_interrupt() functions but there is too much code to understand for
me, sorry.

After some test I found that:

- setting a trap for SIGINT in the script before the loop (trap exit 2)
makes things working

- the same script, without the "sleep", is correctly killed by SIGINT

- if the commands are run directly from the console:
while true; do echo Kill me; sleep 1; done
SIGINT always kills it


This problem is found on BB 1.12.3 and 1.13.1 but not on 1.9.2

Sergio
--
Free software is a matter of liberty, not price. To understand the concept,
you should think of free as in free speech, not as in free beer
- Richard Stallman

http://www.gnu.org/philosophy/free-sw.html
Denys Vlasenko
2008-12-15 21:32:39 UTC
Permalink
Post by Sergio
#!/bin/ash
while true
do
echo Kill me
sleep 1
done
is not killed by a SIGINT (ctrl+c), instead it duplicates in another instance.
A SIGTERM signal correctly kills the script.
I have take a look to ash.c, probably there is something in onsig() and/or
raise_interrupt() functions but there is too much code to understand for
me, sorry.
- setting a trap for SIGINT in the script before the loop (trap exit 2)
makes things working
- the same script, without the "sleep", is correctly killed by SIGINT
while true; do echo Kill me; sleep 1; done
SIGINT always kills it
This problem is found on BB 1.12.3 and 1.13.1 but not on 1.9.2
Yes, one bug was fixed, another one appeared instead :(
I updated testsuite to stop it from happening.
I also installed ash as /bin/sh on my desktop, this ought
to expose it for more testing! :)

Fixed in svn. Download ash.c:

http://busybox.net/cgi-bin/viewcvs.cgi/*checkout*/trunk/busybox/shell/ash.c

and simply replace old one in shell/ with it.

Let me know whether it works.
--
vda
Sergio
2008-12-16 09:53:23 UTC
Permalink
Post by Denys Vlasenko
http://busybox.net/cgi-bin/viewcvs.cgi/*checkout*/trunk/busybox/shell/ash.c
and simply replace old one in shell/ with it.
Let me know whether it works.
Tried on BB 1.13.1, it works!


Thanks
Sergio
--
Free software is a matter of liberty, not price. To understand the concept,
you should think of free as in free speech, not as in free beer
- Richard Stallman

http://www.gnu.org/philosophy/free-sw.html
Sergio
2008-12-16 09:53:23 UTC
Permalink
Post by Denys Vlasenko
http://busybox.net/cgi-bin/viewcvs.cgi/*checkout*/trunk/busybox/shell/ash.c
and simply replace old one in shell/ with it.
Let me know whether it works.
Tried on BB 1.13.1, it works!


Thanks
Sergio
--
Free software is a matter of liberty, not price. To understand the concept,
you should think of free as in free speech, not as in free beer
- Richard Stallman

http://www.gnu.org/philosophy/free-sw.html
Sergio
2008-12-15 17:33:26 UTC
Permalink
Hello list,

I found that a shell script like this:

#!/bin/ash
while true
do
echo Kill me
sleep 1
done

is not killed by a SIGINT (ctrl+c), instead it duplicates in another instance.
A SIGTERM signal correctly kills the script.

I have take a look to ash.c, probably there is something in onsig() and/or
raise_interrupt() functions but there is too much code to understand for
me, sorry.

After some test I found that:

- setting a trap for SIGINT in the script before the loop (trap exit 2)
makes things working

- the same script, without the "sleep", is correctly killed by SIGINT

- if the commands are run directly from the console:
while true; do echo Kill me; sleep 1; done
SIGINT always kills it


This problem is found on BB 1.12.3 and 1.13.1 but not on 1.9.2

Sergio
--
Free software is a matter of liberty, not price. To understand the concept,
you should think of free as in free speech, not as in free beer
- Richard Stallman

http://www.gnu.org/philosophy/free-sw.html
Denys Vlasenko
2008-12-15 21:32:39 UTC
Permalink
Post by Sergio
#!/bin/ash
while true
do
echo Kill me
sleep 1
done
is not killed by a SIGINT (ctrl+c), instead it duplicates in another instance.
A SIGTERM signal correctly kills the script.
I have take a look to ash.c, probably there is something in onsig() and/or
raise_interrupt() functions but there is too much code to understand for
me, sorry.
- setting a trap for SIGINT in the script before the loop (trap exit 2)
makes things working
- the same script, without the "sleep", is correctly killed by SIGINT
while true; do echo Kill me; sleep 1; done
SIGINT always kills it
This problem is found on BB 1.12.3 and 1.13.1 but not on 1.9.2
Yes, one bug was fixed, another one appeared instead :(
I updated testsuite to stop it from happening.
I also installed ash as /bin/sh on my desktop, this ought
to expose it for more testing! :)

Fixed in svn. Download ash.c:

http://busybox.net/cgi-bin/viewcvs.cgi/*checkout*/trunk/busybox/shell/ash.c

and simply replace old one in shell/ with it.

Let me know whether it works.
--
vda
Continue reading on narkive:
Loading...