commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 01/05: proc: Open console earlier.


From: Samuel Thibault
Subject: [hurd] 01/05: proc: Open console earlier.
Date: Fri, 10 Mar 2017 03:33:19 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 83457a27885a177908718839e8a4f356b649f72f
Author: Justus Winter <address@hidden>
Date:   Mon Mar 6 00:14:05 2017 +0100

    proc: Open console earlier.
    
    This way, we can print diagnostics earlier.
    
    * proc/main.c (open_console): New function.
    (main): Call the new function as soon as we have the master device
    port.
---
 proc/main.c | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/proc/main.c b/proc/main.c
index 2c5ce55..5a088b7 100644
--- a/proc/main.c
+++ b/proc/main.c
@@ -99,6 +99,30 @@ increase_priority (void)
   return err;
 }
 
+/* Get our stderr set up to print on the console, in case we have to
+   panic or something.  */
+error_t
+open_console (mach_port_t device_master)
+{
+  static int got_console = 0;
+  mach_port_t cons;
+  error_t err;
+
+  if (got_console)
+    return 0;
+
+  err = device_open (device_master, D_READ|D_WRITE, "console", &cons);
+  if (err)
+    return err;
+
+  stdin = mach_open_devstream (cons, "r");
+  stdout = stderr = mach_open_devstream (cons, "w");
+
+  got_console = 1;
+  mach_port_deallocate (mach_task_self (), cons);
+  return 0;
+}
+
 int
 main (int argc, char **argv, char **envp)
 {
@@ -146,6 +170,10 @@ main (int argc, char **argv, char **envp)
   assert_perror (err);
   mach_port_deallocate (mach_task_self (), startup_port);
 
+  /* Get our stderr set up to print on the console, in case we have
+     to panic or something.  */
+  open_console (_hurd_device_master);
+
   mach_port_mod_refs (mach_task_self (), authserver, MACH_PORT_RIGHT_SEND, 1);
   _hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], authserver);
   mach_port_deallocate (mach_task_self (), boot);
@@ -169,17 +197,6 @@ main (int argc, char **argv, char **envp)
   if (err)
     error (0, err, "Registering task notifications failed");
 
-  {
-    /* Get our stderr set up to print on the console, in case we have
-       to panic or something.  */
-    mach_port_t cons;
-    err = device_open (_hurd_device_master, D_READ|D_WRITE, "console", &cons);
-    assert_perror (err);
-    stdin = mach_open_devstream (cons, "r");
-    stdout = stderr = mach_open_devstream (cons, "w");
-    mach_port_deallocate (mach_task_self (), cons);
-  }
-
   startup = file_name_lookup (_SERVERS_STARTUP, 0, 0);
   if (MACH_PORT_VALID (startup))
     {

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]