-2003-05-08 Bruno Haible <bruno@clisp.org>
+2003-06-13 Bruno Haible <bruno@clisp.org>
+
+ * wait-process.h (wait_subprocess): Add null_stderr argument.
+ * wait-process.c (wait_subprocess): Add null_stderr argument.
+ When !exit_on_error && !null_stderr, still emit error messages, but
+ don't exit.
+ * execute.c (execute): When !exit_on_error && !null_stderr, still
+ emit error messages, but don't exit. Update wait_subprocess call.
+ * pipe-in.c (create_pipe_in): When !exit_on_error && !null_stderr,
+ still emit error messages, but don't exit.
+ * pipe-out.c (create_pipe_out): Likewise.
+ * pipe-bidi.c (create_pipe_bidi): Likewise.
+ * javacomp.c (compile_java_class): Update wait_subprocess call.
+
+2003-06-08 Bruno Haible <bruno@clisp.org>
* Makefile.vms (alloca.h): New rule.
(all, javacomp.obj, javaexec.obj): Depend on it.
if (exitcode == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- return 127;
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ return 127;
}
return exitcode;
{
if (actions_allocated)
posix_spawn_file_actions_destroy (&actions);
- if (exit_on_error)
- error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
- else
- return 127;
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, err,
+ _("%s subprocess failed"), progname);
+ return 127;
}
posix_spawn_file_actions_destroy (&actions);
#else
}
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- return 127;
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ return 127;
}
#endif
- return wait_subprocess (child, progname, exit_on_error);
+ return wait_subprocess (child, progname, null_stderr, exit_on_error);
#endif
}
/* Remove zombie process from process list, and retrieve exit
status. */
- exitstatus = wait_subprocess (child, "gcj", false);
+ exitstatus = wait_subprocess (child, "gcj", true, false);
if (exitstatus != 0)
gcj_present = false;
}
close (ifd[1]);
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- {
- close (ifd[0]);
- close (ofd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ close (ifd[0]);
+ close (ofd[1]);
+ return -1;
}
fd[0] = ifd[0];
{
if (actions_allocated)
posix_spawn_file_actions_destroy (&actions);
- if (exit_on_error)
- error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
- else
- {
- close (ifd[0]);
- close (ifd[1]);
- close (ofd[0]);
- close (ofd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, err,
+ _("%s subprocess failed"), progname);
+ close (ifd[0]);
+ close (ifd[1]);
+ close (ofd[0]);
+ close (ofd[1]);
+ return -1;
}
posix_spawn_file_actions_destroy (&actions);
#else
}
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- {
- close (ifd[0]);
- close (ifd[1]);
- close (ofd[0]);
- close (ofd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ close (ifd[0]);
+ close (ifd[1]);
+ close (ofd[0]);
+ close (ofd[1]);
+ return -1;
}
#endif
close (ofd[0]);
close (ifd[1]);
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- {
- close (ifd[0]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ close (ifd[0]);
+ return -1;
}
fd[0] = ifd[0];
{
if (actions_allocated)
posix_spawn_file_actions_destroy (&actions);
- if (exit_on_error)
- error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
- else
- {
- close (ifd[0]);
- close (ifd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, err,
+ _("%s subprocess failed"), progname);
+ close (ifd[0]);
+ close (ifd[1]);
+ return -1;
}
posix_spawn_file_actions_destroy (&actions);
#else
}
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- {
- close (ifd[0]);
- close (ifd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ close (ifd[0]);
+ close (ifd[1]);
+ return -1;
}
#endif
close (ifd[1]);
close (ofd[0]);
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- {
- close (ofd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ close (ofd[1]);
+ return -1;
}
fd[0] = ofd[1];
{
if (actions_allocated)
posix_spawn_file_actions_destroy (&actions);
- if (exit_on_error)
- error (EXIT_FAILURE, err, _("%s subprocess failed"), progname);
- else
- {
- close (ofd[0]);
- close (ofd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, err,
+ _("%s subprocess failed"), progname);
+ close (ofd[0]);
+ close (ofd[1]);
+ return -1;
}
posix_spawn_file_actions_destroy (&actions);
#else
}
if (child == -1)
{
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess failed"), progname);
- else
- {
- close (ofd[0]);
- close (ofd[1]);
- return -1;
- }
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess failed"), progname);
+ close (ofd[0]);
+ close (ofd[1]);
+ return -1;
}
#endif
close (ofd[0]);
They return the process id of the subprocess. They also return in fd[]
one or two file descriptors for communication with the subprocess.
If the subprocess creation fails: if exit_on_error is true, the main
- process exits with an error message; otherwise, -1 is returned and fd[]
- remain uninitialized.
+ process exits with an error message; otherwise, an error message is given
+ if null_stderr is false, then -1 is returned and fd[] remain uninitialized.
After finishing communication, the caller should call wait_subprocess()
to get rid of the subprocess in the process table.
int
-wait_subprocess (pid_t child, const char *progname, bool exit_on_error)
+wait_subprocess (pid_t child, const char *progname,
+ bool null_stderr, bool exit_on_error)
{
/* waitpid() is just as portable as wait() nowadays. */
WAIT_T status;
break;
}
#endif
- if (exit_on_error)
- error (EXIT_FAILURE, errno, _("%s subprocess"), progname);
- else
- return 127;
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, errno,
+ _("%s subprocess"), progname);
+ return 127;
}
/* One of WIFSIGNALED (status), WIFEXITED (status), WIFSTOPPED (status)
if (WIFSIGNALED (status))
{
- if (exit_on_error)
- error (EXIT_FAILURE, 0, _("%s subprocess got fatal signal %d"),
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, 0,
+ _("%s subprocess got fatal signal %d"),
progname, (int) WTERMSIG (status));
- else
- return 127;
+ return 127;
}
if (WEXITSTATUS (status) == 127)
{
- if (exit_on_error)
- error (EXIT_FAILURE, 0, _("%s subprocess failed"), progname);
- else
- return 127;
+ if (exit_on_error || !null_stderr)
+ error (exit_on_error ? EXIT_FAILURE : 0, 0,
+ _("%s subprocess failed"), progname);
+ return 127;
}
return WEXITSTATUS (status);
}
/* Waiting for a subprocess to finish.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
If it didn't terminate correctly, exit if exit_on_error is true, otherwise
return 127. */
extern int wait_subprocess (pid_t child, const char *progname,
- bool exit_on_error);
+ bool null_stderr, bool exit_on_error);
#endif /* _WAIT_PROCESS_H */