PERFORCE change 82087 for review

soc-tyler soc-tyler at FreeBSD.org
Tue Aug 16 21:52:09 GMT 2005


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

Change 82087 by soc-tyler at soc-tyler_launchd on 2005/08/16 21:51:54

	Making more progress, for some reason tcsh is a bad example job to 
	start launchd(8) with, `sleep 1000` works better. 
	
	Debugging communication from launchctl(1) to launchd(8) via 
	liblaunch.c:launch_msg() (Socket errors :/)

Affected files ...

.. //depot/projects/soc2005/launchd/includes/launch.h#9 edit
.. //depot/projects/soc2005/launchd/launchctl/launchctl.c#7 edit
.. //depot/projects/soc2005/launchd/launchd.c#12 edit
.. //depot/projects/soc2005/launchd/liblaunch.c#5 edit

Differences ...

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

@@ -53,6 +53,18 @@
 #include <stddef.h>
 #include <stdbool.h>
 
+/* 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 LAUNCHCTL_PATH "/sbin/launchctl"
+#define LAUNCHD_PATH "/sbin/launchd"
+#endif
+
+
 /* Keep Mac OS/Darwin specific code in for reference purposes, but don't build it */
 #if defined(__APPLE__) && defined(__MACH__)
 #define _BUILD_DARWIN_

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

@@ -170,7 +170,7 @@
 		exit(EXIT_FAILURE);
 	}
 
-	while ((l = readline(istty ? "launchd% " : NULL))) {
+	while ((l = readline(istty ? "launchctl% " : NULL))) {
 		char *inputstring = l, *argv2[100], **ap = argv2;
 		int i = 0;
 
@@ -1077,6 +1077,10 @@
 	if (resp == NULL) {
 		fprintf(stderr, "launch_msg(): %s\n", strerror(errno));
 		return 1;
+	} else if (resp = 0x1234) {
+		fprintf(stderr, "launch_msg(): %s\t_lc == NULL: liblaunch.c:690\n", 
+			strerror(errno));
+		return 1;
 	} else if (launch_data_get_type(resp) == LAUNCH_DATA_DICTIONARY) {
 		launch_data_dict_iterate(resp, print_jobs, NULL);
 	} else {

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

@@ -114,15 +114,6 @@
 /* XXX: will we really need a local launchd.conf? */
 #define LAUNCHD_CONF ".launchd.conf"
 
-/* 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"
-#else
-#define LAUNCHCTL_PATH "/sbin/launchctl"
-#endif
-
 #ifdef _BUILD_DARWIN_
 #define SECURITY_LIB "/System/Library/Frameworks/Security.framework/Versions/A/Security"
 #define VOLFSDIR "/.vol"

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

@@ -125,7 +125,7 @@
 	
 	_lc = calloc(1, sizeof(struct _launch_client));
 
-	if (!_lc)
+	if (_lc == NULL)
 		return;
 
 	pthread_mutex_init(&_lc->mtx, NULL);
@@ -156,7 +156,7 @@
 			r = connect(lfd, (struct sockaddr *)&sun, sizeof(sun));
 			if (r == -1) {
 				if (getuid() != 0 && fork() == 0)
-					execl("/sbin/launchd", "/sbin/launchd", NULL);
+					execl(LAUNCHD_PATH, LAUNCHD_PATH, NULL);
 				sleep(1);
 			} else {
 				break;
@@ -686,9 +686,10 @@
 
 	pthread_once(&_lc_once, launch_client_init);
 
-	if (!_lc) {
+	// we error out and say "Socket not connected" here
+	if (_lc == NULL) {
 		errno = ENOTCONN;
-		return NULL;
+		return 0x1234;
 	}
 
 	pthread_mutex_lock(&_lc->mtx);


More information about the p4-projects mailing list