Revision
23542
Author
zarzycki@apple.com
Date
2008-03-06 16:20:27 -0800 (Thu, 06 Mar 2008)

Log Message

Misc.

Modified Paths

Diff

Modified: trunk/launchd/src/launchd.c (23541 => 23542)


--- trunk/launchd/src/launchd.c	2008-03-06 22:15:56 UTC (rev 23541)
+++ trunk/launchd/src/launchd.c	2008-03-07 00:20:27 UTC (rev 23542)
@@ -106,12 +106,13 @@
 int
 main(int argc, char *const *argv)
 {
+	const char *stdouterr_path = low_level_debug ? _PATH_CONSOLE : _PATH_DEVNULL;
 	bool sflag = false;
 	int ch;
 
 	testfd_or_openfd(STDIN_FILENO, _PATH_DEVNULL, O_RDONLY);
-	testfd_or_openfd(STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY);
-	testfd_or_openfd(STDERR_FILENO, _PATH_DEVNULL, O_WRONLY);
+	testfd_or_openfd(STDOUT_FILENO, stdouterr_path, O_WRONLY);
+	testfd_or_openfd(STDERR_FILENO, stdouterr_path, O_WRONLY);
 
 	while ((ch = getopt(argc, argv, "s")) != -1) {
 		switch (ch) {

Modified: trunk/launchd/src/launchd_runtime.c (23541 => 23542)


--- trunk/launchd/src/launchd_runtime.c	2008-03-06 22:15:56 UTC (rev 23541)
+++ trunk/launchd/src/launchd_runtime.c	2008-03-07 00:20:27 UTC (rev 23542)
@@ -124,6 +124,7 @@
 static FILE *ourlogfile;
 bool pid1_magic;
 bool do_apple_internal_logging;
+bool low_level_debug;
 
 
 INTERNAL_ABI mach_port_t
@@ -135,7 +136,6 @@
 // static const char *__crashreporter_info__ = "";
 
 static int internal_mask_pri = LOG_UPTO(LOG_NOTICE);
-//static int internal_mask_pri = LOG_UPTO(LOG_DEBUG);
 
 
 INTERNAL_ABI void
@@ -1205,6 +1205,12 @@
 	}
 
 	vsnprintf(newmsg, sizeof(newmsg), message, args);
+
+	if (unlikely(low_level_debug)) {
+		fprintf(stderr, "%s %u\t%s %u\t%s\n", attr->from_name, attr->from_pid,
+				attr->about_name, attr->about_pid, newmsg);
+	}
+
 	logmsg_add(attr, saved_errno, newmsg);
 }
 
@@ -1650,4 +1656,9 @@
 	if (stat("/AppleInternal", &sb) == 0 && stat("/var/db/disableAppleInternal", &sb) == -1) {
 		do_apple_internal_logging = true;
 	}
+
+	if (stat("/var/db/.debug_launchd", &sb) == 0) {
+		internal_mask_pri = LOG_UPTO(LOG_DEBUG);
+		low_level_debug = true;
+	}
 }

Modified: trunk/launchd/src/launchd_runtime.h (23541 => 23542)


--- trunk/launchd/src/launchd_runtime.h	2008-03-06 22:15:56 UTC (rev 23541)
+++ trunk/launchd/src/launchd_runtime.h	2008-03-07 00:20:27 UTC (rev 23542)
@@ -105,6 +105,7 @@
 
 extern bool pid1_magic;
 extern bool do_apple_internal_logging;
+extern bool low_level_debug;
 
 INTERNAL_ABI mach_port_t runtime_get_kernel_port(void);
 

Modified: trunk/launchd/src/liblaunch.c (23541 => 23542)


--- trunk/launchd/src/liblaunch.c	2008-03-06 22:15:56 UTC (rev 23541)
+++ trunk/launchd/src/liblaunch.c	2008-03-07 00:20:27 UTC (rev 23542)
@@ -732,7 +732,8 @@
 	return r;
 }
 
-int launchd_msg_send(launch_t lh, launch_data_t d)
+int
+launchd_msg_send(launch_t lh, launch_data_t d)
 {
 	struct launch_msg_header lmh;
 	struct cmsghdr *cm = NULL;
@@ -948,7 +949,8 @@
 	return resp;
 }
 
-int launchd_msg_recv(launch_t lh, void (*cb)(launch_data_t, void *), void *context)
+int
+launchd_msg_recv(launch_t lh, void (*cb)(launch_data_t, void *), void *context)
 {
 	struct cmsghdr *cm = alloca(4096); 
 	launch_data_t rmsg = NULL;
@@ -1039,7 +1041,8 @@
 	return -1;
 }
 
-launch_data_t launch_data_copy(launch_data_t o)
+launch_data_t
+launch_data_copy(launch_data_t o)
 {
 	launch_data_t r = launch_data_alloc(o->type);
 	size_t i;
@@ -1090,14 +1093,16 @@
 	return false;
 }
 
-static int _fd(int fd)
+int
+_fd(int fd)
 {
 	if (fd >= 0)
 		fcntl(fd, F_SETFD, 1);
 	return fd;
 }
 
-launch_data_t launch_data_new_errno(int e)
+launch_data_t
+launch_data_new_errno(int e)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_ERRNO);
 
@@ -1107,7 +1112,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_fd(int fd)
+launch_data_t
+launch_data_new_fd(int fd)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_FD);
 
@@ -1117,7 +1123,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_machport(mach_port_t p)
+launch_data_t
+launch_data_new_machport(mach_port_t p)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_MACHPORT);
 
@@ -1127,7 +1134,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_integer(long long n)
+launch_data_t
+launch_data_new_integer(long long n)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_INTEGER);
 
@@ -1137,7 +1145,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_bool(bool b)
+launch_data_t
+launch_data_new_bool(bool b)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_BOOL);
 
@@ -1147,7 +1156,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_real(double d)
+launch_data_t
+launch_data_new_real(double d)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_REAL);
 
@@ -1157,7 +1167,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_string(const char *s)
+launch_data_t
+launch_data_new_string(const char *s)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_STRING);
 
@@ -1172,7 +1183,8 @@
 	return r;
 }
 
-launch_data_t launch_data_new_opaque(const void *o, size_t os)
+launch_data_t
+launch_data_new_opaque(const void *o, size_t os)
 {
 	launch_data_t r = launch_data_alloc(LAUNCH_DATA_OPAQUE);