From owner-p4-projects@FreeBSD.ORG Mon Jul 11 03:58:41 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 24C4C16A421; Mon, 11 Jul 2005 03:58:41 +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 F1E4F16A41C for ; Mon, 11 Jul 2005 03:58:40 +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 B254943D45 for ; Mon, 11 Jul 2005 03:58:40 +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 j6B3weoF061159 for ; Mon, 11 Jul 2005 03:58:40 GMT (envelope-from soc-tyler@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j6B3weMG061156 for perforce@freebsd.org; Mon, 11 Jul 2005 03:58:40 GMT (envelope-from soc-tyler@freebsd.org) Date: Mon, 11 Jul 2005 03:58:40 GMT Message-Id: <200507110358.j6B3weMG061156@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 79958 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: Mon, 11 Jul 2005 03:58:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=79958 Change 79958 by soc-tyler@soc-tyler_launchd on 2005/07/11 03:58:02 Add launchd(8)'s init code, and a few modifications to the main source file. Remove final traces of XML code, I think we'll go with a property(3) based configuration file format for the duration of the SoC Affected files ... .. //depot/projects/soc2005/launchd/includes/launchd.h#2 edit .. //depot/projects/soc2005/launchd/init.8#1 add .. //depot/projects/soc2005/launchd/init.c#1 add .. //depot/projects/soc2005/launchd/launchd.c#2 edit .. //depot/projects/soc2005/launchd/launchd_xml.c#3 delete Differences ... ==== //depot/projects/soc2005/launchd/includes/launchd.h#2 (text+ko) ==== @@ -28,7 +28,8 @@ typedef void (*kq_callback)(void *, struct kevent *); extern kq_callback kqsimple_zombie_reaper; -extern mach_port_t launchd_bootstrap_port; +/* Mac OS/NeXT specific */ +//extern mach_port_t launchd_bootstrap_port; extern sigset_t blocked_signals; #ifdef PID1_REAP_ADOPTED_CHILDREN ==== //depot/projects/soc2005/launchd/launchd.c#2 (text+ko) ==== @@ -1,4 +1,31 @@ /* + * $FreeBSD$ + * + * Copyright (c) 2005 R. Tyler Ballance All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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. + */ + +/* * Copyright (c) 2005 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ @@ -20,6 +47,10 @@ * * @APPLE_LICENSE_HEADER_END@ */ + +/* Mac OS specific frameworks (and NeXT-specific for that matter) + * XXX: these need to be implemented or worked around in another manner +-------------------------------------------------------------------------------- #include #include #include @@ -27,15 +58,20 @@ #include #include #endif +-------------------------------------------------------------------------------- + */ #include #include #include #include +/* sys/param.h defines NGROUPS which is necessary for sys/ucred.h */ +#include #include #include #include #include #include +#include #include #include #include @@ -65,7 +101,10 @@ #include "launch_priv.h" #include "launchd.h" +/* Another mach/Mac OS specific header that's been stripped out for FreeBSD + * related work, similar items on FreeBSD might be related to init(8) #include "bootstrap_internal.h" + */ #define LAUNCHD_MIN_JOB_RUN_TIME 10 #define LAUNCHD_REWARD_JOB_RUN_TIME 60 @@ -73,8 +112,10 @@ #define PID1LAUNCHD_CONF "/etc/launchd.conf" #define LAUNCHD_CONF ".launchd.conf" #define LAUNCHCTL_PATH "/bin/launchctl" +/* Mac OS specific #define SECURITY_LIB "/System/Library/Frameworks/Security.framework/Versions/A/Security" #define VOLFSDIR "/.vol" + */ extern char **environ; @@ -180,13 +221,17 @@ static bool launchd_inited = false; static bool shutdown_in_progress = false; static pthread_t mach_server_loop_thread; +/* We undeclared this variable in includes/launchd.h so we will do so here as + * well. (on Darwin, mach_port_t is an unsigned int, it's purpose escapes me.. + * I would assume it's related to mach's bootstrap concept, so I should probably + * hit it as I replace init(8) mach_port_t launchd_bootstrap_port = MACH_PORT_NULL; + */ sigset_t blocked_signals = 0; static char *pending_stdout = NULL; static char *pending_stderr = NULL; -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { static const int sigigns[] = { SIGHUP, SIGINT, SIGPIPE, SIGALRM, SIGTERM, SIGURG, SIGTSTP, SIGTSTP, SIGCONT, /*SIGCHLD,*/ SIGTTIN, SIGTTOU, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF,