@@ -77,16 +77,14 @@ static void notify_parent(void)
7777
7878static NORETURN void die_child (const char * err , va_list params )
7979{
80- char msg [4096 ];
81- int len = vsnprintf (msg , sizeof (msg ), err , params );
82- if (len > sizeof (msg ))
83- len = sizeof (msg );
84-
85- write_in_full (child_err , "fatal: " , 7 );
86- write_in_full (child_err , msg , len );
87- write_in_full (child_err , "\n" , 1 );
80+ vwritef (child_err , "fatal: " , err , params );
8881 exit (128 );
8982}
83+
84+ static void error_child (const char * err , va_list params )
85+ {
86+ vwritef (child_err , "error: " , err , params );
87+ }
9088#endif
9189
9290static inline void set_cloexec (int fd )
@@ -127,9 +125,6 @@ static int wait_or_whine(pid_t pid, const char *argv0, int silent_exec_failure)
127125 if (code == 127 ) {
128126 code = -1 ;
129127 failed_errno = ENOENT ;
130- if (!silent_exec_failure )
131- error ("cannot run %s: %s" , argv0 ,
132- strerror (ENOENT ));
133128 }
134129 } else {
135130 error ("waitpid is confused (%s)" , argv0 );
@@ -217,6 +212,7 @@ int start_command(struct child_process *cmd)
217212 set_cloexec (child_err );
218213 }
219214 set_die_routine (die_child );
215+ set_error_routine (error_child );
220216
221217 close (notify_pipe [0 ]);
222218 set_cloexec (notify_pipe [1 ]);
@@ -283,14 +279,14 @@ int start_command(struct child_process *cmd)
283279 } else {
284280 execvp (cmd -> argv [0 ], (char * const * ) cmd -> argv );
285281 }
286- /*
287- * Do not check for cmd->silent_exec_failure; the parent
288- * process will check it when it sees this exit code.
289- */
290- if (errno == ENOENT )
282+ if (errno == ENOENT ) {
283+ if (!cmd -> silent_exec_failure )
284+ error ("cannot run %s: %s" , cmd -> argv [0 ],
285+ strerror (ENOENT ));
291286 exit (127 );
292- else
287+ } else {
293288 die_errno ("cannot exec '%s'" , cmd -> argv [0 ]);
289+ }
294290 }
295291 if (cmd -> pid < 0 )
296292 error ("cannot fork() for %s: %s" , cmd -> argv [0 ],
0 commit comments