From owner-p4-projects@FreeBSD.ORG Wed Aug 24 16:34:47 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 3D06A16A421; Wed, 24 Aug 2005 16:34:47 +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 F2B0C16A41F for ; Wed, 24 Aug 2005 16:34:46 +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 B9C0943D46 for ; Wed, 24 Aug 2005 16:34:46 +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 j7OGYk83051358 for ; Wed, 24 Aug 2005 16:34:46 GMT (envelope-from soc-tyler@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j7OGYkWH051355 for perforce@freebsd.org; Wed, 24 Aug 2005 16:34:46 GMT (envelope-from soc-tyler@freebsd.org) Date: Wed, 24 Aug 2005 16:34:46 GMT Message-Id: <200508241634.j7OGYkWH051355@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 82499 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: Wed, 24 Aug 2005 16:34:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=82499 Change 82499 by soc-tyler@soc-tyler_launchd on 2005/08/24 16:34:27 Set a definite, development-only LAUNCHD_PATH and LAUNCHCTL_PATH so that I can start launchd as a child of launchctl to ensure that they can "talk" to each other via launch_msg() Add suggested fix for ADC Bug #4229882 which references launchd idly dying despite launchctl still maintaining an open socket connection to it (i.e. when the daemon is not running jobs) Oh, and add a few more fprintf()'s to make sure I know what I'm doing ;) Affected files ... .. //depot/projects/soc2005/launchd/includes/launch.h#10 edit .. //depot/projects/soc2005/launchd/launchd.c#13 edit .. //depot/projects/soc2005/launchd/liblaunch.c#11 edit Differences ... ==== //depot/projects/soc2005/launchd/includes/launch.h#10 (text+ko) ==== @@ -53,14 +53,15 @@ #include #include -/* XXX: if _LAUNCHD_ is defined, then I'm working with the source code, so the - * the relevant launchctl(1) executable is in our current working dir. - */ #ifdef _LAUNCHD_ -#define LAUNCHCTL_PATH "./launchctl/launchctl" -#define LAUNCHD_PATH "./launchd" -#else +#define LAUNCHD_PATH "/home/tyler/perforce/launchd/launchd" +#define LAUNCHCTL_PATH "/home/tyler/perforce/launchd/launchctl/launchctl" +#endif + +#ifndef LAUNCHCTL_PATH #define LAUNCHCTL_PATH "/sbin/launchctl" +#endif +#ifndef LAUNCHD_PATH #define LAUNCHD_PATH "/sbin/launchd" #endif ==== //depot/projects/soc2005/launchd/launchd.c#13 (text+ko) ==== @@ -368,7 +368,7 @@ if (readcfg_pid == 0) init_pre_kevent(); } else { - if (TAILQ_EMPTY(&jobs)) { + if (TAILQ_EMPTY(&jobs) && TAILQ_EMPTY(&connections)) { /* launched on demand */ timeoutp = &timeout; } else if (shutdown_in_progress && total_children == 0) { @@ -525,6 +525,10 @@ snprintf(ourdir, sizeof(ourdir), "%s/%u.%u", LAUNCHD_SOCK_PREFIX, getuid(), getpid()); snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%u.%u/sock", LAUNCHD_SOCK_PREFIX, getuid(), getpid()); setenv(LAUNCHD_SOCKET_ENV, sun.sun_path, 1); +#ifdef _LAUNCHD_ + fprintf(stderr, "Setting the socket path to \"%s\"\n", sun.sun_path); +#endif + } else { snprintf(ourdir, sizeof(ourdir), "%s/%u", LAUNCHD_SOCK_PREFIX, getuid()); snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%u/sock", LAUNCHD_SOCK_PREFIX, getuid()); ==== //depot/projects/soc2005/launchd/liblaunch.c#11 (text+ko) ==== @@ -125,6 +125,8 @@ #ifdef _LAUNCHD_ fprintf(stderr,"starting launch_client_init() in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"where = \"%s\"\n", where); + fprintf(stderr,"_launchd_fd = \"%s\"\n", _launchd_fd); #endif _lc = calloc(1, sizeof(struct _launch_client)); @@ -178,7 +180,7 @@ for (tries = 0; tries < 10; tries++) { r = connect(lfd, (struct sockaddr *)&sun, sizeof(sun)); if (r == -1) { - if (getuid() != 0 && fork() == 0) + if (fork() == 0) execl(LAUNCHD_PATH, LAUNCHD_PATH, NULL); sleep(1); } else {