]>
Commit | Line | Data |
---|---|---|
e6aa4d74 MT |
1 | diff -Nrup a/job.c b/job.c |
2 | --- a/job.c 2013-10-05 19:12:24.000000000 -0400 | |
3 | +++ b/job.c 2014-02-03 18:15:48.681085207 -0500 | |
4 | @@ -1020,7 +1020,7 @@ free_child (struct child *child) | |
5 | ||
6 | EINTRLOOP (r, write (job_fds[1], &token, 1)); | |
7 | if (r != 1) | |
8 | - pfatal_with_name (_("write jobserver")); | |
9 | + pfatal_with_name_err (_("write jobserver"), errno); | |
10 | ||
11 | DB (DB_JOBS, (_("Released token for child %p (%s).\n"), | |
12 | child, child->file->name)); | |
13 | @@ -1956,6 +1956,7 @@ new_job (struct file *file) | |
14 | #else | |
15 | /* Set interruptible system calls, and read() for a job token. */ | |
16 | set_child_handler_action_flags (1, waiting_jobs != NULL); | |
17 | + errno = 0; | |
18 | got_token = read (job_rfd, &token, 1); | |
19 | saved_errno = errno; | |
20 | set_child_handler_action_flags (0, waiting_jobs != NULL); | |
21 | @@ -1972,10 +1973,14 @@ new_job (struct file *file) | |
22 | #ifndef WINDOWS32 | |
23 | /* If the error _wasn't_ expected (EINTR or EBADF), punt. Otherwise, | |
24 | go back and reap_children(), and try again. */ | |
25 | - errno = saved_errno; | |
26 | - if (errno != EINTR && errno != EBADF) | |
27 | - pfatal_with_name (_("read jobs pipe")); | |
28 | - if (errno == EBADF) | |
29 | + if (saved_errno != EINTR && saved_errno != EBADF) | |
30 | + { | |
31 | + if (got_token == 0) | |
32 | + fatal (NILF, _("read jobs pipe EOF")); | |
33 | + else | |
34 | + pfatal_with_name_err (_("read jobs pipe"), saved_errno); | |
35 | + } | |
36 | + if (saved_errno == EBADF) | |
37 | DB (DB_JOBS, ("Read returned EBADF.\n")); | |
38 | #endif | |
39 | } | |
40 | @@ -2117,7 +2122,9 @@ load_too_high (void) | |
41 | error (NILF, | |
42 | _("cannot enforce load limits on this operating system")); | |
43 | else | |
44 | - perror_with_name (_("cannot enforce load limit: "), "getloadavg"); | |
45 | + perror_with_name_err (_("cannot enforce load limit: "), | |
46 | + "getloadavg", errno); | |
47 | + | |
48 | } | |
49 | lossage = errno; | |
50 | load = 0; | |
51 | diff -Nrup a/main.c b/main.c | |
52 | --- a/main.c 2014-02-03 17:49:03.255939340 -0500 | |
53 | +++ b/main.c 2014-02-03 18:06:25.768024183 -0500 | |
54 | @@ -1580,7 +1580,7 @@ main (int argc, char **argv, char **envp | |
55 | || (job_rfd = dup (job_fds[0])) < 0) | |
56 | { | |
57 | if (errno != EBADF) | |
58 | - pfatal_with_name (_("dup jobserver")); | |
59 | + pfatal_with_name_err (_("dup jobserver"), errno); | |
60 | ||
61 | error (NILF, | |
62 | _("warning: jobserver unavailable: using -j1. Add '+' to parent make rule.")); | |
63 | @@ -1787,13 +1787,13 @@ main (int argc, char **argv, char **envp | |
64 | strcat (template, DEFAULT_TMPFILE); | |
65 | outfile = output_tmpfile (&stdin_nm, template); | |
66 | if (outfile == 0) | |
67 | - pfatal_with_name (_("fopen (temporary file)")); | |
68 | + pfatal_with_name_err (_("fopen (temporary file)"), errno); | |
69 | while (!feof (stdin) && ! ferror (stdin)) | |
70 | { | |
71 | char buf[2048]; | |
72 | unsigned int n = fread (buf, 1, sizeof (buf), stdin); | |
73 | if (n > 0 && fwrite (buf, 1, n, outfile) != n) | |
74 | - pfatal_with_name (_("fwrite (temporary file)")); | |
75 | + pfatal_with_name_err (_("fwrite (temporary file)"), errno); | |
76 | } | |
77 | fclose (outfile); | |
78 | ||
79 | @@ -2030,7 +2030,8 @@ main (int argc, char **argv, char **envp | |
80 | char c = '+'; | |
81 | ||
82 | if (pipe (job_fds) < 0 || (job_rfd = dup (job_fds[0])) < 0) | |
83 | - pfatal_with_name (_("creating jobs pipe")); | |
84 | + pfatal_with_name_err (_("creating jobs pipe"), errno); | |
85 | + | |
86 | #endif | |
87 | ||
88 | /* Every make assumes that it always has one job it can run. For the | |
89 | @@ -2050,7 +2051,8 @@ main (int argc, char **argv, char **envp | |
90 | ||
91 | EINTRLOOP (r, write (job_fds[1], &c, 1)); | |
92 | if (r != 1) | |
93 | - pfatal_with_name (_("init jobserver pipe")); | |
94 | + pfatal_with_name_err (_("init jobserver pipe"), errno); | |
95 | + | |
96 | } | |
97 | #endif | |
98 | ||
99 | @@ -2474,7 +2476,7 @@ main (int argc, char **argv, char **envp | |
100 | /* If there is a temp file from reading a makefile from stdin, get rid of | |
101 | it now. */ | |
102 | if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT) | |
103 | - perror_with_name (_("unlink (temporary file): "), stdin_nm); | |
104 | + perror_with_name_err (_("unlink (temporary file): "), stdin_nm, errno); | |
105 | ||
106 | /* If there were no command-line goals, use the default. */ | |
107 | if (goals == 0) | |
108 | diff -Nrup a/makeint.h b/makeint.h | |
109 | --- a/makeint.h 2014-02-03 17:49:03.265939424 -0500 | |
110 | +++ b/makeint.h 2014-02-03 18:09:31.738695318 -0500 | |
111 | @@ -436,6 +436,8 @@ void fatal (const gmk_floc *flocp, const | |
112 | void die (int) __attribute__ ((noreturn)); | |
113 | void pfatal_with_name (const char *) __attribute__ ((noreturn)); | |
114 | void perror_with_name (const char *, const char *); | |
115 | +void pfatal_with_name_err (const char *, int errnum) __attribute__ ((noreturn)); | |
116 | +void perror_with_name_err (const char *, const char *, int errnum); | |
117 | #define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s)) | |
118 | void *xmalloc (unsigned int); | |
119 | void *xcalloc (unsigned int); | |
120 | diff -Nrup a/output.c b/output.c | |
121 | --- a/output.c 2013-10-05 19:12:24.000000000 -0400 | |
122 | +++ b/output.c 2014-02-03 18:22:48.617908701 -0500 | |
123 | @@ -746,17 +746,31 @@ fatal (const gmk_floc *flocp, const char | |
124 | /* Print an error message from errno. */ | |
125 | ||
126 | void | |
127 | +perror_with_name_err (const char *str, const char *name, int errnum) | |
128 | +{ | |
129 | + error (NILF, _("%s%s: %s"), str, name, strerror (errnum)); | |
130 | +} | |
131 | + | |
132 | +void | |
133 | perror_with_name (const char *str, const char *name) | |
134 | { | |
135 | - error (NILF, _("%s%s: %s"), str, name, strerror (errno)); | |
136 | + perror_with_name_err (str, name, errno); | |
137 | } | |
138 | ||
139 | /* Print an error message from errno and exit. */ | |
140 | ||
141 | void | |
142 | +pfatal_with_name_err (const char *name, int errnum) | |
143 | +{ | |
144 | + fatal (NILF, _("%s: %s"), name, strerror (errnum)); | |
145 | + | |
146 | + /* NOTREACHED */ | |
147 | +} | |
148 | + | |
149 | +void | |
150 | pfatal_with_name (const char *name) | |
151 | { | |
152 | - fatal (NILF, _("%s: %s"), name, strerror (errno)); | |
153 | + pfatal_with_name_err (name, errno); | |
154 | ||
155 | /* NOTREACHED */ | |
156 | } |