unblock_input ();
if (pid < 0)
- report_file_errno ("Doing vfork", Qnil, child_errno);
+ report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, child_errno);
/* Close our file descriptors, except for callproc_fd[CALLPROC_PIPEREAD]
since we will use that to read input from. */
executable directory by the parent.
On GNUish hosts, either exec or return an error number.
- On MS-Windows, either return a pid or signal an error.
+ On MS-Windows, either return a pid or return -1 and set errno.
On MS-DOS, either return an exit status or signal an error. */
CHILD_SETUP_TYPE
/* Spawn the child. (See w32proc.c:sys_spawnve). */
cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env);
reset_standard_handles (in, out, err, handles);
- if (cpid == -1)
- /* An error occurred while trying to spawn the process. */
- report_file_error ("Spawning child process", Qnil);
return cpid;
#else /* not WINDOWSNT */
is shutting down. */
Lisp_Object Vrun_hooks;
-/* The value of num_nonmacro_input_events as of the last time we
- started to enter the debugger. If we decide to enter the debugger
- again when this is still equal to num_nonmacro_input_events, then we
- know that the debugger itself has an error, and we should just
- signal the error instead of entering an infinite loop of debugger
- invocations. */
-
-static intmax_t when_entered_debugger;
-
/* The function from which the last `signal' was called. Set in
Fsignal. */
/* FIXME: We should probably get rid of this! */
? debug_on_quit
: wants_debugger (Vdebug_on_error, conditions))
&& ! skip_debugger (conditions, combined_data)
- /* RMS: What's this for? */
+ /* See commentary on definition of
+ `internal-when-entered-debugger'. */
&& when_entered_debugger < num_nonmacro_input_events)
{
call_debugger (list2 (Qerror, combined_data));
still determine whether to handle the particular condition. */);
Vdebug_on_signal = Qnil;
+ /* The value of num_nonmacro_input_events as of the last time we
+ started to enter the debugger. If we decide to enter the debugger
+ again when this is still equal to num_nonmacro_input_events, then we
+ know that the debugger itself has an error, and we should just
+ signal the error instead of entering an infinite loop of debugger
+ invocations. */
+ DEFSYM (Qinternal_when_entered_debugger, "internal-when-entered-debugger");
+ DEFVAR_INT ("internal-when-entered-debugger", when_entered_debugger,
+ doc: /* The number of keyboard events as of last time `debugger' was called.
+Used to avoid infinite loops if the debugger itself has an error.
+Don't set this unless you're sure that can't happen. */);
+
/* When lexical binding is being used,
Vinternal_interpreter_environment is non-nil, and contains an alist
of lexically-bound variable, or (t), indicating an empty
extern void setup_process_coding_systems (Lisp_Object);
/* Defined in callproc.c. */
-#ifndef DOS_NT
-# define CHILD_SETUP_TYPE _Noreturn void
-#else
+#ifdef DOS_NT
# define CHILD_SETUP_TYPE int
+# define CHILD_SETUP_ERROR_DESC "Spawning child process"
+#else
+# define CHILD_SETUP_TYPE _Noreturn void
+# define CHILD_SETUP_ERROR_DESC "Doing vfork"
#endif
+
extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, bool, Lisp_Object);
extern void init_callproc_1 (void);
extern void init_callproc (void);
unblock_input ();
if (pid < 0)
- report_file_errno ("Doing vfork", Qnil, vfork_errno);
+ report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, vfork_errno);
else
{
/* vfork succeeded. */
(split-string-and-unquote (buffer-string)))
(should (equal initial-shell "nil"))
(should-not (equal initial-shell shell))))
+
+(ert-deftest call-process-w32-debug-spawn-error ()
+ "Check that debugger runs on `call-process' failure (Bug#33016)."
+ (skip-unless (eq system-type 'windows-nt))
+ (let* ((debug-on-error t)
+ (have-called-debugger nil)
+ (debugger (lambda (&rest _)
+ (setq have-called-debugger t)
+ ;; Allow entering the debugger later in the same
+ ;; test run, before going back to the command
+ ;; loop.
+ (setq internal-when-entered-debugger -1))))
+ (should (eq :got-error ;; NOTE: `should-error' would inhibit debugger.
+ (condition-case-unless-debug ()
+ ;; On Windows, "nul.FOO" act like an always-empty
+ ;; file for any FOO, in any directory. So this
+ ;; passes Emacs' test for the file's existence,
+ ;; and ensures we hit an error in the w32 process
+ ;; spawn code.
+ (call-process "c:/nul.exe")
+ (error :got-error))))
+ (should have-called-debugger)))
(string-to-list "stdout\n")
(string-to-list "stderr\n"))))))
+(ert-deftest make-process-w32-debug-spawn-error ()
+ "Check that debugger runs on `make-process' failure (Bug#33016)."
+ (skip-unless (eq system-type 'windows-nt))
+ (let* ((debug-on-error t)
+ (have-called-debugger nil)
+ (debugger (lambda (&rest _)
+ (setq have-called-debugger t)
+ ;; Allow entering the debugger later in the same
+ ;; test run, before going back to the command
+ ;; loop.
+ (setq internal-when-entered-debugger -1))))
+ (should (eq :got-error ;; NOTE: `should-error' would inhibit debugger.
+ (condition-case-unless-debug ()
+ ;; Emacs doesn't search for absolute filenames, so
+ ;; the error will be hit in the w32 process spawn
+ ;; code.
+ (make-process :name "test" :command '("c:/No-Such-Command"))
+ (error :got-error))))
+ (should have-called-debugger)))
+
(ert-deftest make-process/file-handler/found ()
"Check that the ‘:file-handler’ argument of ‘make-process’
works as expected if a file name handler is found."