View Full Version : What SIG signal gets sent on button press?
KennX
08-16-2007, 04:12 PM
Does anyone know what SIG gets sent when we press the main button to close an app and exit back to the Springboard? I am trying to initiate a trap in a shell script and the ones that I have used thus far SIGHUP, SIGTERM, etc haven't worked so rather than going through all 29 or so signals I figured someone here probably knew the info.
Much appreciated!
-KennX
MetalRat
08-16-2007, 06:53 PM
Does anyone know what SIG gets sent when we press the main button to close an app and exit back to the Springboard? I am trying to initiate a trap in a shell script and the ones that I have used thus far SIGHUP, SIGTERM, etc haven't worked so rather than going through all 29 or so signals I figured someone here probably knew the info.
Much appreciated!
-KennX
Are you attempting to do something like this?
=======
# traptest.sh
trap "echo Booh!" SIGINT SIGTERM
echo "pid is $$"
while : # This is the same as "while true".
do
sleep 60 # This script is not really doing anything.
done
========
Or are you trying to detect when a different application launched from a shell script has exited...?
(BTW the above will work in bash not sure about the vanilla shell)
MetalRat
08-16-2007, 06:58 PM
Are you attempting to do something like this?
=======
# traptest.sh
trap "echo Booh!" SIGINT SIGTERM
echo "pid is $$"
while : # This is the same as "while true".
do
sleep 60 # This script is not really doing anything.
done
========
Or are you trying to detect when a different application launched from a shell script has exited...?
(BTW the above will work in bash not sure about the vanilla shell)
Just had a thought, you could write a separate script that basically traps any SIG it recieves and writes it to a file, but it may be forced to exit before it finishes echoing....
sumorai
08-16-2007, 08:16 PM
I would assume it's something in the frameworks that is used to signal an app to quit rather than a unix signal.
RVN84
08-17-2007, 03:44 AM
it could be a unix sig, and the hardware has probably 2 sig levels, one being press, and one being the hold...
i also assume you mean the home button right...
I was thinking about it and i kinda wish that the home button would take you straight to the phone dialpad, when already on the home screen... afterall, this is still supposed to be a phone, right, so with a double-press of the home button from within any app, we can get to the dialpad.
just an idea
KennX
08-17-2007, 05:18 AM
Okay, what I'd like to be able to do is to put something in a script that will terminate the script when the home button is pressed so I'd like to be able to trap for that event. I've got a particular script that I call like an app from an icon and it will run but just stay on the default.icon screen and never leave that (even when the home button is pressed) so I have to re-start the iPhone (which obviously defeats the purpose of the script. I can jump out of a script by killing the Springboard.app like I do in iSwap but that will not do for what I have in mind. Was hoping that I could put a trap to exit on a SIG event triggered by the home button press.
-KennX
MetalRat
08-17-2007, 12:40 PM
Are you attempting to do something like this?
=======
# traptest.sh
trap "echo Booh!" SIGINT SIGTERM
echo "pid is $$"
while : # This is the same as "while true".
do
sleep 60 # This script is not really doing anything.
done
========
Or are you trying to detect when a different application launched from a shell script has exited...?
(BTW the above will work in bash not sure about the vanilla shell)
Okay, what I'd like to be able to do is to put something in a script that will terminate the script when the home button is pressed so I'd like to be able to trap for that event. I've got a particular script that I call like an app from an icon and it will run but just stay on the default.icon screen and never leave that (even when the home button is pressed) so I have to re-start the iPhone (which obviously defeats the purpose of the script. I can jump out of a script by killing the Springboard.app like I do in iSwap but that will not do for what I have in mind. Was hoping that I could put a trap to exit on a SIG event triggered by the home button press.
-KennX
Well a common trick would be to launch a script that writes its PID to a lockfile. The second time the script it launched it checks the lockfile for the pid, and kills it, then exits. So in effect the script will either run, if its not running, or kill if it is. (if you see what I mean) not a perfect solution, but it works.
If you are really clever you can change the icon to tell you if it is running, or not ;-)
(I am assuming you are running this script as a background process via nohup)
MR
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.