Revision
23918
Author
dsorresso@apple.com
Date
2009-05-01 18:13:22 -0700 (Fri, 01 May 2009)

Log Message

<rdar://problem/6847675> STD:VSC: /tset/POSIX.upe/ps/ps.ex 814 Failed

Modified Paths

Diff

Modified: trunk/launchd/src/launchd.c (23917 => 23918)


--- trunk/launchd/src/launchd.c	2009-05-01 21:54:48 UTC (rev 23917)
+++ trunk/launchd/src/launchd.c	2009-05-02 01:13:22 UTC (rev 23918)
@@ -125,13 +125,12 @@
 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, stdouterr_path, O_WRONLY);
-	testfd_or_openfd(STDERR_FILENO, stdouterr_path, O_WRONLY);
+	testfd_or_openfd(STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY);
+	testfd_or_openfd(STDERR_FILENO, _PATH_DEVNULL, O_WRONLY);
 
 	if (pid1_magic && g_use_gmalloc) {
 		if (!getenv("DYLD_INSERT_LIBRARIES")) {
@@ -162,10 +161,12 @@
 	launchd_runtime_init();
 
 	if( pid1_magic ) {
-		if( low_level_debug ) {
-			g_console = stdout;
-		} else if( launchd_assumes((g_console = fopen(_PATH_CONSOLE, "w")) != NULL) ) {
-			_fd(fileno(g_console));
+		int cfd = -1;
+		if( launchd_assumes((cfd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY)) != -1) ) {
+			_fd(cfd);
+			if( !launchd_assumes((g_console = fdopen(cfd, "w")) != NULL) ) {
+				close(cfd);
+			}
 		}
 	}
 

Modified: trunk/launchd/src/launchd_core_logic.c (23917 => 23918)


--- trunk/launchd/src/launchd_core_logic.c	2009-05-01 21:54:48 UTC (rev 23917)
+++ trunk/launchd/src/launchd_core_logic.c	2009-05-02 01:13:22 UTC (rev 23918)
@@ -3501,21 +3501,12 @@
 			}
 		} else if( pid1_magic && g_console && kev->ident == (uintptr_t)fileno(g_console) ) {
 			int cfd = -1;
-			if( low_level_debug ) {
-				if( jobmgr_assumes(jm, (stdout = freopen(_PATH_CONSOLE, "w", stdout)) != NULL) ) {
-					cfd = fileno(stdout);
+			if( launchd_assumes((cfd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY)) != -1) ) {
+				_fd(cfd);
+				if( !launchd_assumes((g_console = fdopen(cfd, "w")) != NULL) ) {
+					close(cfd);
 				}
-				g_console = stdout;
-			} else {
-				if( jobmgr_assumes(jm, (g_console = freopen(_PATH_CONSOLE, "w", g_console)) != NULL) ) {
-					cfd = fileno(g_console);
-				}
 			}
-			
-			if( cfd != -1 ) {
-				jobmgr_assumes(jm, kevent_mod((uintptr_t)cfd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_REVOKE, 0, jm) != -1);
-				_fd(cfd);
-			}
 		}
 		break;
 	default: