From owner-p4-projects@FreeBSD.ORG Fri Sep 2 05:49:56 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BF1FA16A421; Fri, 2 Sep 2005 05:49:55 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9485216A41F for ; Fri, 2 Sep 2005 05:49:55 +0000 (GMT) (envelope-from soc-tyler@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48D2B43D49 for ; Fri, 2 Sep 2005 05:49:55 +0000 (GMT) (envelope-from soc-tyler@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j825ntRl002552 for ; Fri, 2 Sep 2005 05:49:55 GMT (envelope-from soc-tyler@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j825nsKL002549 for perforce@freebsd.org; Fri, 2 Sep 2005 05:49:54 GMT (envelope-from soc-tyler@freebsd.org) Date: Fri, 2 Sep 2005 05:49:54 GMT Message-Id: <200509020549.j825nsKL002549@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-tyler@freebsd.org using -f From: soc-tyler To: Perforce Change Reviews Cc: Subject: PERFORCE change 82998 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2005 05:49:56 -0000 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;