summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-03-06 00:14:05 +0100
committerJustus Winter <justus@gnupg.org>2017-03-06 00:14:05 +0100
commit83457a27885a177908718839e8a4f356b649f72f (patch)
tree289bcc152495f522f6f4fb22d661ec4d8b4feb19 /proc
parentdb7dd39b84be0371536c9ccec907cd918476c0ea (diff)
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.
Diffstat (limited to 'proc')
-rw-r--r--proc/main.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/proc/main.c b/proc/main.c
index 2c5ce5534..5a088b71f 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))
{