Date: Fri, 2 Sep 2005 05:49:54 GMT From: soc-tyler <soc-tyler@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 82998 for review Message-ID: <200509020549.j825nsKL002549@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=82998 Change 82998 by soc-tyler@soc-tyler_launchd on 2005/09/02 05:49:34 Start to add quickstart command, still segfaulting on the "running" portion of the function Affected files ... .. //depot/projects/soc2005/launchd/launchctl/launchctl.c#19 edit Differences ... ==== //depot/projects/soc2005/launchd/launchctl/launchctl.c#19 (text+ko) ==== @@ -106,6 +106,7 @@ static int load_and_unload_cmd(int argc, char *const argv[]); //static int reload_cmd(int argc, char *const argv[]); static int start_stop_remove_cmd(int argc, char *const argv[]); +static int quickstart_cmd(int argc, char *const argv[]); static int submit_cmd(int argc, char *const argv[]); static int list_cmd(int argc, char *const argv[]); @@ -132,6 +133,7 @@ { "unload", load_and_unload_cmd, "Unload configuration files and/or directories" }, // { "reload", reload_cmd, "Reload configuration files and/or directories" }, { "start", start_stop_remove_cmd, "Start specified job" }, + { "quickstart", quickstart_cmd, "Load and start specified"}, // { "stop", start_stop_remove_cmd, "Stop specified job" }, { "submit", submit_cmd, "Submit a job from the command line" }, { "remove", start_stop_remove_cmd, "Remove/stop specified job" }, @@ -1214,6 +1216,44 @@ } } +static int quickstart_cmd(int argc, char *const argv[]) { + launch_data_t pass1, pass2; // need two passes for "compat" reasons + launch_data_t resp, msg, label; + + label = launch_data_alloc(LAUNCH_DATA_STRING); + + /* XXX: I need to add some error checking after the deadline */ + + pass1 = launch_data_alloc(LAUNCH_DATA_ARRAY); + pass2 = launch_data_alloc(LAUNCH_DATA_ARRAY); + + readpath(argv[1], pass1, pass2, false, true, false); + + /* XXX: assuming data has been read correctly */ + submit_job_pass(pass1); + + launch_data_free(pass2); + + /* end load portion */ + label = launch_data_dict_lookup(pass1, LAUNCH_JOBKEY_LABEL); + + msg = launch_data_alloc(LAUNCH_DATA_DICTIONARY); + launch_data_dict_insert(msg, label, LAUNCH_KEY_STARTJOB); + + + resp = launch_msg(msg); + launch_data_free(msg); + + if (resp == NULL) { + fprintf(stderr, "launch_msg(): %s\n", strerror(errno)); + return 1; + } + + launch_data_free(resp); + + return 0; +} + static int list_cmd(int argc, char *const argv[]) { launch_data_t resp, msg;help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509020549.j825nsKL002549>
