I have a few bash shell scripts running from SpringBoard icons. A couple just move files around on the phone and work fine, but 3 require a network connection and only 1 works properly (a simple "wget the last line copied"). I think launchd is killing the other two mid-execution.
This is the plist I use on both. The names are different, of course, but the format is the same. I assume this has something to do with the plist.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>nail.sh</string>
<key>CFBundleIdentifier</key>
<string>com.foo.nail</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Nail</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
I have both scripts in /Applications/their.app/their.sh with all the files needed to run them from a SpringBoard icon. If I open MobileTerminal and type /Applications/their.app/their.sh, they both run fine, but both crash when running from a SB icon.
The first is a script using nail (a.k.a. mailx) to send mail through my gmail address with a simple:
#! /bin/sh
echo "some text" | mail "user@address.com"
I have mail set up correctly. Running from Terminal, it sends the mail. Running from an icon, it runs but dumps the mail into /var/mobile/dead.letter (typical mailx failure) and I get an error in syslog. Here are two examples from running it twice, same error except the hex changes every time:
Nov 2 02:48:16 30 com.apple.launchd[1] (UIKitApplication:com.foo.nail[0xc671]): (UIKitApplication:com.foo.nail[0xc671]) Throttling respawn: Will start in 2147483647 seconds
Nov 2 02:50:00 30 com.apple.launchd[1] (UIKitApplication:com.foo.nail[0x5cd1]): (UIKitApplication:com.foo.nail[0x5cd1]) Throttling respawn: Will start in 2147483647 seconds
The other script uses wget in a function to download a list of about a dozen webpages which are then processed, but it never gets through all the wgets. It should take about 1 second per page, so around 12-15 seconds to run to the end. It runs for several seconds and downloads most of the pages before dying, and it's not a problem with wgetting the pages. Taking out different pages, moving the order around, pinging the site before the wget... nothing helps. It keeps dying on the 7-8th page. This is in syslog:
Code:
Nov 2 03:31:47 30 SpringBoard[958]: com.foo.bigwget failed to launch in time \nelapsed total CPU time (seconds): 5.890 (user 1.710, system 4.180), 29% CPU \nelapsed application CPU time (seconds): 0.320, 2% CPU
Nov 2 03:31:47 30 SpringBoard[958]: Forcing crash report of com.foo.bigwget...
Nov 2 03:31:48 30 SpringBoard[958]: Finished crash reporting.
Nov 2 03:31:48 30 com.apple.launchd[1] (UIKitApplication:com.foo.bigwget[0x6d92][1235]): (UIKitApplication:com.foo.bigwget[0x6d92]) Exited: Killed
Nov 2 03:31:48 30 com.apple.launchd[1] (UIKitApplication:com.foo.bigwget[0x6d92]): (UIKitApplication:com.foo.bigwget[0x6d92]) Throttling respawn: Will start in 2147483627 seconds
Nov 2 03:31:48 30 SpringBoard[958]: Application 'ibigwget' exited abnormally with signal 9: Killed
Nov 2 03:31:48 30 SpringBoard[958]: Setting springboard visible = 1
Nov 2 03:31:48 30 ReportCrash[1294]: Could not save crash report to disk!
Nov 2 03:31:48 30 ReportCrash[1294]: Incident Identifier: 478E9F75-6944-4815-B4A7-D329B4594F55
Nov 2 03:31:48 30 ReportCrash[1294]: CrashReporter Key: 582c70f125b8660f26110882f4236298aff6c003
Nov 2 03:31:48 30 ReportCrash[1294]: Process: sh [1235]
Nov 2 03:31:48 30 ReportCrash[1294]: Path: /bin/sh
Nov 2 03:31:48 30 ReportCrash[1294]: Identifier: sh
Nov 2 03:31:48 30 ReportCrash[1294]: Version: ??? (???)
Nov 2 03:31:48 30 ReportCrash[1294]: Code Type: ARM (Native)
Nov 2 03:31:48 30 ReportCrash[1294]: Parent Process: launchd [1]
Nov 2 03:31:48 30 ReportCrash[1294]:
Nov 2 03:31:48 30 ReportCrash[1294]: Date/Time: 2009-11-02 03:31:47.583 -0500
Nov 2 03:31:48 30 ReportCrash[1294]: OS Version: iPhone OS 3.0.1 (7A400)
Nov 2 03:31:48 30 ReportCrash[1294]: Report Version: 104
Nov 2 03:31:48 30 ReportCrash[1294]:
Nov 2 03:31:48 30 ReportCrash[1294]: Exception Type: 00000020
Nov 2 03:31:48 30 ReportCrash[1294]: Exception Codes: 0x8badf00d
Nov 2 03:31:48 30 ReportCrash[1294]: Highlighted Thread: 0
Nov 2 03:31:48 30 ReportCrash[1294]:
Nov 2 03:31:48 30 ReportCrash[1294]: Application Specific Information:
Nov 2 03:31:48 30 ReportCrash[1294]: com.foo.bigwget failed to launch in time
Nov 2 03:31:48 30 ReportCrash[1294]: elapsed total CPU time (seconds): 5.890 (user 1.710, system 4.180), 29% CPU
Nov 2 03:31:48 30 ReportCrash[1294]: elapsed application CPU time (seconds): 0.320, 2% CPU
So, from what I can figure, they just aren't being launched the way launchd wants, and the SOB is killing them. I've tried reading through launchd and plist docs but for a Linux guy, this stuffs all greek and all seems to be geared around using launchd/launchctl as cron, but I just want these to run at the tap of an icon and not die. Is there a "CFBundlePleaseDontKillMeLaunchd" I should set to "true" in the plist?