X-Git-Url: https://git.saurik.com/uikittools.git/blobdiff_plain/2dd5da1605dad121be0de8d4be4361c58808b350..68d2b30b8a240347caa0937c75cfbf0079b7a3a5:/sbreload.c diff --git a/sbreload.c b/sbreload.c index dc669d5..3db5a68 100644 --- a/sbreload.c +++ b/sbreload.c @@ -1,3 +1,42 @@ +/* UIKit Tools - command-line utilities for UIKit + * Copyright (C) 2008-2012 Jay Freeman (saurik) +*/ + +/* Modified BSD License {{{ */ +/* + * Redistribution and use in source and binary + * forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the + * above copyright notice, this list of conditions + * and the following disclaimer. + * 2. Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions + * and the following disclaimer in the documentation + * and/or other materials provided with the + * distribution. + * 3. The name of the author may not be used to endorse + * or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/* }}} */ + #include #include @@ -121,10 +160,12 @@ void stop() { sleep(1); } +#define SpringBoard_plist "/System/Library/LaunchDaemons/com.apple.SpringBoard.plist" + int main(int argc, const char *argv[]) { _assert(argc == 1, "usage: sbreload"); - CFDictionaryRef plist = CreateMyPropertyListFromFile("/System/Library/LaunchDaemons/com.apple.SpringBoard.plist"); + CFDictionaryRef plist = CreateMyPropertyListFromFile(SpringBoard_plist); _assert(plist != NULL, "CreateMyPropertyListFromFile() == NULL"); launch_data_t job = CF2launch_data(plist); @@ -157,8 +198,18 @@ int main(int argc, const char *argv[]) { launch_data_free(response); - fprintf(stderr, "notify_post(com.apple.mobile.springboard_teardown)\n"); - notify_post("com.apple.mobile.springboard_teardown"); + // 600 is being used to approximate 4.x/5.x boundary + if (kCFCoreFoundationVersionNumber < 600) { + fprintf(stderr, "notify_post(com.apple.mobile.springboard_teardown)\n"); + notify_post("com.apple.mobile.springboard_teardown"); + } else { + // XXX: this code is preferable to launchctl unoad but it requires libvproc? :( + //vproc_err_t *error = _vproc_send_signal_by_label(label, VPROC_MAGIC_UNLOAD_SIGNAL); + //_assert(error == NULL, "_vproc_send_signal_by_label(UNLOAD) != NULL"); + + fprintf(stderr, "launchctl unload SpringBoard.plist\n"); + system("launchctl unload " SpringBoard_plist); + } if (pid != -1) { fprintf(stderr, "waiting for kill(%u) != 0...\n", pid);