PERFORCE change 82010 for review

soc-tyler soc-tyler at FreeBSD.org
Mon Aug 15 04:21:48 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=82010

Change 82010 by soc-tyler at soc-tyler_launchd on 2005/08/15 04:21:32

	i figure I might as well submit some of my minor/trivial changes while I continue to debug this sucker. I am totally losing the "most p4 submissions" contest to cdjones; why doesnt `set follow-fork-mode child` work in gdb on FreeBSD?

Affected files ...

.. //depot/projects/soc2005/launchd/includes/launch.h#8 edit
.. //depot/projects/soc2005/launchd/launchctl/launchctl.c#6 edit
.. //depot/projects/soc2005/launchd/launchd.c#11 edit
.. //depot/projects/soc2005/launchd/liblaunch.c#4 edit

Differences ...

==== //depot/projects/soc2005/launchd/includes/launch.h#8 (text+ko) ====

@@ -88,13 +88,20 @@
 #define LAUNCH_JOBKEY_PID			"PID"
 #define LAUNCH_JOBKEY_UMASK			"Umask"
 #define LAUNCH_JOBKEY_NICE			"Nice"
+
 // FreeBSD's sysctl() interface doesn't allow per-process attributes :/
 #ifdef _BUILD_DARWIN_
 #define LAUNCH_JOBKEY_LOWPRIORITYIO		"LowPriorityIO"
 #endif
+
 #define LAUNCH_JOBKEY_SESSIONCREATE		"SessionCreate"
 #define LAUNCH_JOBKEY_SOFTRESOURCELIMITS	"SoftResourceLimits"
 #define LAUNCH_JOBKEY_HARDRESOURCELIMITS	"HardResourceLimits"
+/*
+ * sipc = job_get_bool(j->ldj, LAUNCH_JOBKEY_SERVICEIPC);
+ * job_get_bool (j=0x0, key=0x4f <Error reading address 0x4f: Bad address>)
+    at launchd.c:687
+ */
 #define LAUNCH_JOBKEY_SERVICEIPC		"ServiceIPC"
 #define LAUNCH_JOBKEY_STANDARDOUTPATH		"StandardOutPath"
 #define LAUNCH_JOBKEY_STANDARDERRORPATH		"StandardErrorPath"

==== //depot/projects/soc2005/launchd/launchctl/launchctl.c#6 (text+ko) ====

@@ -128,6 +128,7 @@
 static int getrusage_cmd(int argc, char *const argv[]);
 
 static int help_cmd(int argc, char *const argv[]);
+static int exit_cmd(int argc, char *const argv[]);
 
 static const struct {
 	const char *name;
@@ -153,6 +154,7 @@
 	{ "log",	logupdate_cmd,		"Adjust the logging level or mask of launchd" },
 	{ "umask",	umask_cmd,		"Change launchd's umask" },
 	{ "help",	help_cmd,		"This help output" },
+	{"exit", 	exit_cmd, 		"Exit launchctl" },
 };
 
 int main(int argc, char *const argv[])
@@ -870,6 +872,12 @@
 	return 0;
 }
 
+static int exit_cmd(int argc, char *const argv[]) {
+	exit(0);
+	
+	return 0; // god help us if we get here ;)
+}
+
 static int _fd(int fd)
 {
 	if (fd >= 0)

==== //depot/projects/soc2005/launchd/launchd.c#11 (text+ko) ====

@@ -252,8 +252,7 @@
 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,
@@ -555,7 +554,6 @@
 				goto out_bad;
 			}
 		} else {
-			// XXX: launchd[12139]: mkdir("/var/launchd/1001"): Permission denied
 			syslog(LOG_ERR, "mkdir(\"%s\"): %m", LAUNCHD_SOCK_PREFIX);
 			goto out_bad;
 		}
@@ -1680,6 +1678,7 @@
 			job_ignore(j);
 		break;
 	case 0:
+		/* child */
 		close(execspair[0]);
 		/* wait for our parent to say they've attached a kevent to us */
 		read(_fd(execspair[1]), &c, sizeof(c));
@@ -1699,6 +1698,7 @@
 		job_start_child(j, execspair[1]);
 		break;
 	default:
+		/* parent */
 		close(execspair[1]);
 		j->execfd = _fd(execspair[0]);
 		if (sipc) {
@@ -2180,6 +2180,11 @@
 	TAILQ_FIRST(&jobs)->firstborn = true;
 }
 
+//! Setup the loopback device 
+/*! For performance and networking reasons, we are setting up the 
+ *  loopback device from inside launchd(8), making it easy to start 
+ *  network related daemons before the kernel actually brings up networking 
+ */
 static void loopback_setup(void)
 {
 	struct ifaliasreq ifra;
@@ -2247,7 +2252,9 @@
 	close(s);
 	close(s6);
 }
-/*
+
+//! Work around for OpenFirmware based machines
+/*!
  * This workaround fixes a bug or two cause because the Xnu kernel wasn't 
  * passing boot-args from OFW to PID 1 correctly, yikes!
  */
@@ -2348,7 +2355,7 @@
  * allows verification against keychains, etc.
  * http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/security.1.html
  * 
- * This is here because of the securityd team at Apple Inc.....i.e. we don't really need it ;) 
+ * It's here because of the securityd team at Apple Inc. i.e. we don't really need it ;) 
  */
 #ifdef _BUILD_DARWIN_
 __private_extern__ void launchd_SessionCreate(const char *who)

==== //depot/projects/soc2005/launchd/liblaunch.c#4 (text+ko) ====

@@ -183,8 +183,7 @@
 	_lc = NULL;
 }
 
-launch_data_t launch_data_alloc(launch_data_type_t t)
-{
+launch_data_t launch_data_alloc(launch_data_type_t t) {
 	launch_data_t d = calloc(1, sizeof(struct _launch));
 
 	if (d) {


More information about the p4-projects mailing list