1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
From b04364bcdcd1a209cb3e2762e09a42247bcde5f0 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Thu, 28 Apr 2016 18:57:54 +0200
Subject: [PATCH hurd 5/5] startup: write all messages to stderr
This avoids the need to flush the buffer and works around a weird
problem with 'puts' not printing a newline.
* startup/startup.c: Write all messages to stderr.
---
startup/startup.c | 61 +++++++++++++++++++++++++------------------------------
1 file changed, 28 insertions(+), 33 deletions(-)
diff --git a/startup/startup.c b/startup/startup.c
index 66f960c..f90b524 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -173,17 +173,15 @@ reboot_mach (int flags)
{
if (fakeboot)
{
- printf ("%s: Would %s Mach with flags %#x\n",
- program_invocation_short_name, BOOT (flags), flags);
- fflush (stdout);
+ fprintf (stderr, "%s: Would %s Mach with flags %#x\n",
+ program_invocation_short_name, BOOT (flags), flags);
exit (1);
}
else
{
error_t err;
- printf ("%s: %sing Mach (flags %#x)...\n",
- program_invocation_short_name, BOOT (flags), flags);
- fflush (stdout);
+ fprintf (stderr, "%s: %sing Mach (flags %#x)...\n",
+ program_invocation_short_name, BOOT (flags), flags);
sleep (5);
while ((err = host_reboot (host_priv, flags)))
error (0, err, "reboot");
@@ -207,17 +205,16 @@ notify_shutdown (const char *msg)
for (n = ntfy_tasks; n != NULL; n = n->next)
{
error_t err;
- printf ("%s: notifying %s of %s...",
- program_invocation_short_name, n->name, msg);
- fflush (stdout);
+ fprintf (stderr, "%s: notifying %s of %s...",
+ program_invocation_short_name, n->name, msg);
+
err = startup_dosync (n->notify_port, 60000); /* 1 minute to reply */
if (err == MACH_SEND_INVALID_DEST)
- puts ("(no longer present)");
+ fprintf (stderr, "(no longer present)\n");
else if (err)
- puts (strerror (err));
+ fprintf (stderr, "%s\n", strerror (err));
else
- puts ("done");
- fflush (stdout);
+ fprintf (stderr, "done\n");
}
}
@@ -276,20 +273,18 @@ reboot_system (int flags)
}
if (!(pi->state & PI_NOPARENT))
{
- printf ("%s: Killing pid %d\n",
- program_invocation_short_name, pp[ind]);
- fflush (stdout);
+ fprintf (stderr, "%s: Killing pid %d\n",
+ program_invocation_short_name, pp[ind]);
task_terminate (task);
}
if (noise_len > 0)
munmap (noise, noise_len);
}
}
- printf ("%s: Killing proc server\n", program_invocation_short_name);
- fflush (stdout);
+ fprintf (stderr, "%s: Killing proc server\n",
+ program_invocation_short_name);
task_terminate (proctask);
- printf ("%s: Exiting", program_invocation_short_name);
- fflush (stdout);
+ fprintf (stderr, "%s: Exiting", program_invocation_short_name);
}
reboot_mach (flags);
}
@@ -359,7 +354,7 @@ run (const char *server, mach_port_t *ports, task_t *task)
if (bootstrap_args & RB_INITNAME)
{
- printf ("Server file name (default %s): ", server);
+ fprintf (stderr, "Server file name (default %s): ", server);
if (getstring (buf, sizeof (buf)))
prog = buf;
}
@@ -381,7 +376,7 @@ run (const char *server, mach_port_t *ports, task_t *task)
0, task);
if (bootstrap_args & RB_KDB)
{
- printf ("Pausing for %s\n", prog);
+ fprintf (stderr, "Pausing for %s\n", prog);
getchar ();
}
err = file_exec (file, *task, 0,
@@ -397,7 +392,8 @@ run (const char *server, mach_port_t *ports, task_t *task)
error (0, err, "%s", prog);
}
- printf ("File name for server %s (or nothing to reboot): ", server);
+ fprintf (stderr, "File name for server %s (or nothing to reboot): ",
+ server);
if (getstring (buf, sizeof (buf)))
prog = buf;
else
@@ -405,7 +401,7 @@ run (const char *server, mach_port_t *ports, task_t *task)
}
if (verbose)
- fprintf (stderr, "started %s\n", prog);
+ fprintf (stderr, stderr, "started %s\n", prog);
/* Dead-name notification on the task port will tell us when it dies,
so we can crash if we don't make it to a fully bootstrapped Hurd. */
@@ -431,7 +427,7 @@ run_for_real (char *filename, char *args, int arglen, mach_port_t ctty,
char buf[512];
do
{
- printf ("File name [%s]: ", filename);
+ fprintf (stderr, "File name [%s]: ", filename);
if (getstring (buf, sizeof (buf)) && *buf)
filename = buf;
file = file_name_lookup (filename, O_EXEC, 0);
@@ -467,7 +463,7 @@ run_for_real (char *filename, char *args, int arglen, mach_port_t ctty,
}
if (bootstrap_args & RB_KDB)
{
- printf ("Pausing for %s\n", filename);
+ fprintf (stderr, "Pausing for %s\n", filename);
getchar ();
}
progname = strrchr (filename, '/');
@@ -690,11 +686,11 @@ main (int argc, char **argv, char **envp)
default_ports[INIT_PORT_BOOTSTRAP] = startup;
run ("/hurd/proc", default_ports, &proctask);
- printf (" proc");
- fflush (stdout);
+ if (! verbose)
+ fprintf (stderr, " proc");
run ("/hurd/auth", default_ports, &authtask);
- printf (" auth");
- fflush (stdout);
+ if (! verbose)
+ fprintf (stderr, " auth");
default_ports[INIT_PORT_BOOTSTRAP] = MACH_PORT_NULL;
/* Wait for messages. When both auth and proc have started, we
@@ -805,8 +801,7 @@ launch_core_servers (void)
err = proc_mark_exec (fsproc);
assert_perror (err);
- printf (".\n");
- fflush (stdout);
+ fprintf (stderr, ".\n");
/* Tell the proc server our msgport. Be sure to do this after we are all
done making requests of proc. Once we have done this RPC, proc
@@ -1141,7 +1136,7 @@ start_child (const char *prog, char **progargs)
if (bootstrap_args & RB_KDB)
{
- printf ("Pausing for %s\n", args);
+ fprintf (stderr, "Pausing for %s\n", args);
getchar ();
}
--
2.1.4
|