]>
Commit | Line | Data |
---|---|---|
ebd9bd39 MT |
1 | diff -urp make-3.81/misc.c make-3.81-pm/misc.c |
2 | --- make-3.81/misc.c 2006-04-01 08:36:40.000000000 +0200 | |
3 | +++ make-3.81-pm/misc.c 2008-09-22 12:45:18.000000000 +0200 | |
4 | @@ -311,17 +311,31 @@ strerror (int errnum) | |
5 | /* Print an error message from errno. */ | |
6 | ||
7 | void | |
8 | +perror_with_name_err (const char *str, const char *name, int errnum) | |
9 | +{ | |
10 | + error (NILF, _("%s%s: %s"), str, name, strerror (errnum)); | |
11 | +} | |
12 | + | |
13 | +void | |
14 | perror_with_name (const char *str, const char *name) | |
15 | { | |
16 | - error (NILF, _("%s%s: %s"), str, name, strerror (errno)); | |
17 | + perror_with_name_err (str, name, errno); | |
18 | } | |
19 | ||
20 | /* Print an error message from errno and exit. */ | |
21 | ||
22 | void | |
23 | +pfatal_with_name_err (const char *name, int errnum) | |
24 | +{ | |
25 | + fatal (NILF, _("%s: %s"), name, strerror (errnum)); | |
26 | + | |
27 | + /* NOTREACHED */ | |
28 | +} | |
29 | + | |
30 | +void | |
31 | pfatal_with_name (const char *name) | |
32 | { | |
33 | - fatal (NILF, _("%s: %s"), name, strerror (errno)); | |
34 | + pfatal_with_name_err (name, errno); | |
35 | ||
36 | /* NOTREACHED */ | |
37 | } | |
38 | diff -urp make-3.81/main.c make-3.81-pm/main.c | |
39 | --- make-3.81/main.c 2008-09-22 12:45:07.000000000 +0200 | |
40 | +++ make-3.81-pm/main.c 2008-09-22 12:45:18.000000000 +0200 | |
41 | @@ -1502,13 +1502,13 @@ main (int argc, char **argv, char **envp | |
42 | strcat (template, DEFAULT_TMPFILE); | |
43 | outfile = open_tmpfile (&stdin_nm, template); | |
44 | if (outfile == 0) | |
45 | - pfatal_with_name (_("fopen (temporary file)")); | |
46 | + pfatal_with_name_err (_("fopen (temporary file)"), errno); | |
47 | while (!feof (stdin) && ! ferror (stdin)) | |
48 | { | |
49 | char buf[2048]; | |
50 | unsigned int n = fread (buf, 1, sizeof (buf), stdin); | |
51 | if (n > 0 && fwrite (buf, 1, n, outfile) != n) | |
52 | - pfatal_with_name (_("fwrite (temporary file)")); | |
53 | + pfatal_with_name_err (_("fwrite (temporary file)"), errno); | |
54 | } | |
55 | (void) fclose (outfile); | |
56 | ||
57 | @@ -1681,7 +1681,7 @@ main (int argc, char **argv, char **envp | |
58 | else if ((job_rfd = dup (job_fds[0])) < 0) | |
59 | { | |
60 | if (errno != EBADF) | |
61 | - pfatal_with_name (_("dup jobserver")); | |
62 | + pfatal_with_name_err (_("dup jobserver"), errno); | |
63 | ||
64 | error (NILF, | |
65 | _("warning: jobserver unavailable: using -j1. Add `+' to parent make rule.")); | |
66 | @@ -1721,7 +1721,7 @@ main (int argc, char **argv, char **envp | |
67 | char c = '+'; | |
68 | ||
69 | if (pipe (job_fds) < 0 || (job_rfd = dup (job_fds[0])) < 0) | |
70 | - pfatal_with_name (_("creating jobs pipe")); | |
71 | + pfatal_with_name_err (_("creating jobs pipe"), errno); | |
72 | ||
73 | /* Every make assumes that it always has one job it can run. For the | |
74 | submakes it's the token they were given by their parent. For the | |
75 | @@ -1736,7 +1736,7 @@ main (int argc, char **argv, char **envp | |
76 | ||
77 | EINTRLOOP (r, write (job_fds[1], &c, 1)); | |
78 | if (r != 1) | |
79 | - pfatal_with_name (_("init jobserver pipe")); | |
80 | + pfatal_with_name_err (_("init jobserver pipe"), errno); | |
81 | } | |
82 | ||
83 | /* Fill in the jobserver_fds struct for our children. */ | |
84 | @@ -2151,7 +2151,7 @@ main (int argc, char **argv, char **envp | |
85 | /* If there is a temp file from reading a makefile from stdin, get rid of | |
86 | it now. */ | |
87 | if (stdin_nm && unlink (stdin_nm) < 0 && errno != ENOENT) | |
88 | - perror_with_name (_("unlink (temporary file): "), stdin_nm); | |
89 | + perror_with_name_err (_("unlink (temporary file): "), stdin_nm, errno); | |
90 | ||
91 | { | |
92 | int status; | |
93 | diff -urp make-3.81/make.h make-3.81-pm/make.h | |
94 | --- make-3.81/make.h 2008-09-22 12:45:07.000000000 +0200 | |
95 | +++ make-3.81-pm/make.h 2008-09-22 12:45:18.000000000 +0200 | |
96 | @@ -414,6 +414,8 @@ extern void die PARAMS ((int)) __attribu | |
97 | extern void log_working_directory PARAMS ((int)); | |
98 | extern void pfatal_with_name PARAMS ((const char *)) __attribute__ ((noreturn)); | |
99 | extern void perror_with_name PARAMS ((const char *, const char *)); | |
100 | +extern void pfatal_with_name_err PARAMS ((const char *, int errnum)) __attribute__ ((noreturn)); | |
101 | +extern void perror_with_name_err PARAMS ((const char *, const char *, int errnum)); | |
102 | extern char *savestring PARAMS ((const char *, unsigned int)); | |
103 | extern char *concat PARAMS ((const char *, const char *, const char *)); | |
104 | extern char *xmalloc PARAMS ((unsigned int)); | |
105 | diff -urp make-3.81/job.c make-3.81-pm/job.c | |
106 | --- make-3.81/job.c 2006-03-20 04:03:04.000000000 +0100 | |
107 | +++ make-3.81-pm/job.c 2008-09-22 12:45:18.000000000 +0200 | |
108 | @@ -859,7 +859,7 @@ free_child (struct child *child) | |
109 | ||
110 | EINTRLOOP (r, write (job_fds[1], &token, 1)); | |
111 | if (r != 1) | |
112 | - pfatal_with_name (_("write jobserver")); | |
113 | + pfatal_with_name_err (_("write jobserver"), errno); | |
114 | ||
115 | DB (DB_JOBS, (_("Released token for child 0x%08lx (%s).\n"), | |
116 | (unsigned long int) child, child->file->name)); | |
117 | @@ -1699,6 +1699,7 @@ new_job (struct file *file) | |
118 | ||
119 | /* Set interruptible system calls, and read() for a job token. */ | |
120 | set_child_handler_action_flags (1, waiting_jobs != NULL); | |
121 | + errno = 0; | |
122 | got_token = read (job_rfd, &token, 1); | |
123 | saved_errno = errno; | |
124 | set_child_handler_action_flags (0, waiting_jobs != NULL); | |
125 | @@ -1713,10 +1714,14 @@ new_job (struct file *file) | |
126 | ||
127 | /* If the error _wasn't_ expected (EINTR or EBADF), punt. Otherwise, | |
128 | go back and reap_children(), and try again. */ | |
129 | - errno = saved_errno; | |
130 | - if (errno != EINTR && errno != EBADF) | |
131 | - pfatal_with_name (_("read jobs pipe")); | |
132 | - if (errno == EBADF) | |
133 | + if (saved_errno != EINTR && saved_errno != EBADF) | |
134 | + { | |
135 | + if (got_token == 0) | |
136 | + fatal (NILF, _("read jobs pipe EOF")); | |
137 | + else | |
138 | + pfatal_with_name_err (_("read jobs pipe"), saved_errno); | |
139 | + } | |
140 | + if (saved_errno == EBADF) | |
141 | DB (DB_JOBS, ("Read returned EBADF.\n")); | |
142 | } | |
143 | #endif | |
144 | @@ -1831,7 +1836,7 @@ load_too_high (void) | |
145 | error (NILF, | |
146 | _("cannot enforce load limits on this operating system")); | |
147 | else | |
148 | - perror_with_name (_("cannot enforce load limit: "), "getloadavg"); | |
149 | + perror_with_name_err (_("cannot enforce load limit: "), "getloadavg", errno); | |
150 | } | |
151 | lossage = errno; | |
152 | load = 0; |