annotate src/w32proc.c @ 112364:42e22c4f06b7

Move all DEFVAR'd globals into a structure -- threading infrastructure * globals.h: New file. * xterm.h (Vx_pixel_size_width_font_regexp): Remove declaration. * window.h (Vinitial_window_system, Vminibuf_scroll_window) (Vwindow_system_version): Remove declaration. * w32term.h (Vw32_enable_palette) (Vx_pixel_size_width_font_regexp): Remove declaration. * w32menu.c (Voverriding_local_map) (Voverriding_local_map_menu_flag): Remove declaration. * w32inevt.c (Vw32_alt_is_meta, Vw32_apps_modifier) (Vw32_capslock_is_shiftlock, Vw32_enable_caps_lock) (Vw32_enable_num_lock, Vw32_lwindow_modifier) (Vw32_pass_lwindow_to_system, Vw32_pass_rwindow_to_system) (Vw32_phantom_key_code, Vw32_recognize_altgr) (Vw32_rwindow_modifier, Vw32_scroll_lock_modifier) (w32_use_full_screen_buffer): Remove declaration. * w32.c (Vsystem_configuration, Vw32_downcase_file_names) (Vw32_generate_fake_inodes, Vw32_get_true_file_attributes) (w32_num_mouse_buttons, w32_pipe_read_delay): Remove declaration. * termopts.h (Vtruncate_partial_width_windows, inverse_video) (no_redraw_on_reenter, visible_bell): Remove declaration. * sysdep.c (Vsystem_name): Remove declaration. * syntax.h (parse_sexp_lookup_properties): Remove declaration. * menu.h (Vmenu_updating_frame): Remove declaration. * macros.h (Vexecuting_kbd_macro, executing_kbd_macro_index): Remove declaration. * lisp.h (Vafter_init_time, Vafter_load_alist) (Vauto_save_list_file_name, Vbefore_init_time, Vcommand_history) (Vcompletion_regexp_list, Vcurrent_load_list) (Vcurrent_prefix_arg, Vdata_directory, Vdebug_on_error) (Vdoc_directory, Vdoc_file_name, Vdynamic_library_alist) (Vexec_directory, Vexec_path, Vexec_suffixes) (Vface_font_rescale_alist, Vface_ignored_fonts, Vfeatures) (Vhelp_form, Vhistory_length, Vinhibit_field_text_motion) (Vinhibit_quit, Vinhibit_read_only, Vinhibit_redisplay) (Vinstallation_directory, Vinvocation_directory) (Vinvocation_name, Vload_file_rep_suffixes, Vload_history) (Vload_suffixes, Vmark_even_if_inactive, Vmemory_full) (Vmessage_log_max, Vobarray, Vprint_length, Vprint_level) (Vpurify_flag, Vquit_flag, Vsaved_region_selection) (Vscalable_fonts_allowed, Vselect_active_regions) (Vshell_file_name, Vstandard_input, Vstandard_output) (Vsystem_name, Vtemporary_file_directory, Vthrow_on_input) (Vtop_level, Vtty_erase_char, Vundo_outer_limit) (Vuser_login_name, Vwindow_scroll_functions) (Vwindow_system_version, Vx_no_window_manager) (Vx_resource_class, Vx_resource_name, baud_rate) (completion_ignore_case, debug_on_next_call, gc_cons_threshold) (history_delete_duplicates, inhibit_x_resources) (last_nonmenu_event, load_in_progress, max_specpdl_size) (minibuffer_auto_raise, print_escape_newlines, scroll_margin) (use_dialog_box, use_file_dialog): Remove declaration. Include globals.h. * keymap.h (Voverriding_local_map) (Voverriding_local_map_menu_flag, meta_prefix_char): Remove declaration. * keyboard.h (Vdouble_click_time, Vfunction_key_map) (Vinput_method_function, Vkey_translation_map) (Vlucid_menu_bar_dirty_flag, Vthis_original_command) (do_mouse_tracking, extra_keyboard_modifiers) (num_nonmacro_input_events): Remove declaration. * intervals.h (Vchar_property_alias_alist) (Vdefault_text_properties, Vinhibit_point_motion_hooks) (Vtext_property_default_nonsticky): Remove declaration. * gtkutil.h (x_gtk_file_dialog_help_text) (x_gtk_show_hidden_files, x_gtk_use_old_file_dialog) (x_gtk_whole_detached_tool_bar): Remove declaration. * frame.h (Vdefault_frame_alist, Vframe_alpha_lower_limit) (Vmenu_bar_mode, Vmouse_highlight, Vterminal_frame) (Vtool_bar_mode, Vx_resource_class, Vx_resource_name) (focus_follows_mouse): Remove declaration. * fontset.h (Valternate_fontname_alist, Vfontset_alias_alist) (Vignore_relative_composition, Votf_script_alist) (Vuse_default_ascent, Vvertical_centering_font_regexp): Remove declaration. * font.h (Vfont_log): Remove declaration. * dosfns.h (Vdos_display_scancodes, Vdos_version) (Vdos_windows_version, dos_codepage, dos_country_code) (dos_decimal_point, dos_hyper_key, dos_keyboard_layout) (dos_keypad_mode, dos_super_key, dos_timezone_offset): Remove declaration. * disptab.h (Vglyph_table, Vstandard_display_table): Remove declaration. * dispextern.h (Vface_remapping_alist, Vglyphless_char_display) (Vmouse_autoselect_window, Voverflow_newline_into_fringe) (Vshow_trailing_whitespace, Vtool_bar_button_margin) (Vtool_bar_style, cursor_in_echo_area, display_hourglass_p) (inverse_video, mode_line_in_non_selected_windows) (tool_bar_button_relief, tool_bar_max_label_size) (underline_minimum_offset) (unibyte_display_via_language_environment, x_stretch_cursor_p): Remove declaration. * composite.h (Vauto_composition_function) (Vcomposition_function_table): Remove declaration. * commands.h (Vexecuting_kbd_macro) (Vminibuffer_local_completion_map) (Vminibuffer_local_filename_completion_map) (Vminibuffer_local_filename_must_match_map) (Vminibuffer_local_map, Vminibuffer_local_must_match_map) (Vminibuffer_local_ns_map, Vthis_command) (Vunread_command_events, cursor_in_echo_area) (last_command_event, last_nonmenu_event, unread_command_char): Remove declaration. * coding.h (Vcoding_system_for_read, Vcoding_system_for_write) (Vdefault_file_name_coding_system) (Vdefault_process_coding_system, Vfile_name_coding_system) (Vlast_coding_system_used, Vlocale_coding_system) (Vselect_safe_coding_system_function) (Vtranslation_table_for_input, coding_system_require_warning) (eol_mnemonic_dos, eol_mnemonic_mac, eol_mnemonic_undecided) (eol_mnemonic_unix, inherit_process_coding_system): Remove declaration. * charset.h (Vcharset_list, Vcurrent_iso639_language): Remove declaration. * character.h (Vauto_fill_chars, Vchar_direction_table) (Vchar_script_table, Vchar_width_table, Vprintable_chars) (Vscript_representative_chars, Vtranslation_table_vector) (Vunicode_category_table): Remove declaration. * ccl.h (Vfont_ccl_encoder_alist): Remove declaration. * buffer.h (Vafter_change_functions, Vbefore_change_functions) (Vdeactivate_mark, Vfirst_change_hook, Vtransient_mark_mode) (inhibit_modification_hooks): Remove declaration. * xterm.c (syms_of_xterm): Update. (Vx_alt_keysym, Vx_hyper_keysym, Vx_keysym_table) (Vx_meta_keysym, Vx_super_keysym, Vx_toolkit_scroll_bars) (x_mouse_click_focus_ignore_position) (x_underline_at_descent_line) (x_use_underline_position_properties): Remove. * xsmfns.c (syms_of_xsmfns): Update. (Vx_session_id, Vx_session_previous_id): Remove. * xsettings.c (syms_of_xsettings): Update. (Vxft_settings, use_system_font): Remove. * xselect.c (syms_of_xselect): Update. (Vselection_converter_alist, Vx_lost_selection_functions) (Vx_sent_selection_functions, x_selection_timeout): Remove. * xfns.c (syms_of_xfns): Update. (Vgtk_version_string, Vmotif_version_string) (Vx_cursor_fore_pixel, Vx_hourglass_pointer_shape) (Vx_max_tooltip_size, Vx_mode_pointer_shape) (Vx_no_window_manager, Vx_nontext_pointer_shape) (Vx_pixel_size_width_font_regexp, Vx_pointer_shape) (Vx_sensitive_text_pointer_shape) (Vx_window_horizontal_drag_shape, x_gtk_file_dialog_help_text) (x_gtk_show_hidden_files, x_gtk_use_old_file_dialog) (x_gtk_use_system_tooltips, x_gtk_whole_detached_tool_bar): Remove. * xfaces.c (syms_of_xfaces): Update. (Vface_default_stipple, Vface_font_rescale_alist) (Vface_ignored_fonts, Vface_new_frame_defaults) (Vface_remapping_alist, Vfont_list_limit) (Vscalable_fonts_allowed, Vtty_defined_color_alist): Remove. * xdisp.c (syms_of_xdisp): Update. (Vauto_resize_tool_bars, Vblink_cursor_alist) (Vdisplay_pixels_per_inch, Vfontification_functions) (Vframe_title_format, Vglobal_mode_string) (Vglyphless_char_display, Vhourglass_delay, Vhscroll_step) (Vicon_title_format, Vinhibit_redisplay) (Vline_number_display_limit, Vline_prefix) (Vmax_mini_window_height, Vmenu_bar_update_hook) (Vmenu_updating_frame, Vmessage_log_max) (Vmouse_autoselect_window, Vnobreak_char_display) (Voverlay_arrow_position, Voverlay_arrow_string) (Voverlay_arrow_variable_list, Vredisplay_end_trigger_functions) (Vresize_mini_windows, Vshow_trailing_whitespace) (Vtool_bar_border, Vtool_bar_button_margin, Vtool_bar_style) (Vtruncate_partial_width_windows, Vvoid_text_area_pointer) (Vwindow_scroll_functions, Vwindow_size_change_functions) (Vwindow_text_change_functions, Vwrap_prefix) (auto_raise_tool_bar_buttons_p, automatic_hscrolling_p) (debug_end_pos, display_hourglass_p, emacs_scroll_step) (highlight_nonselected_windows, hscroll_margin) (inhibit_eval_during_redisplay, inhibit_free_realized_faces) (inhibit_menubar_update, inhibit_try_cursor_movement) (inhibit_try_window_id, inhibit_try_window_reusing) (line_number_display_limit_width) (make_cursor_line_fully_visible_p, message_truncate_lines) (mode_line_inverse_video, multiple_frames, overline_margin) (scroll_conservatively, scroll_margin, tool_bar_button_relief) (tool_bar_max_label_size, underline_minimum_offset) (unibyte_display_via_language_environment, x_stretch_cursor_p): Remove. * window.c (syms_of_window): Update. (Vminibuf_scroll_window, Vother_window_scroll_buffer) (Vrecenter_redisplay, Vscroll_preserve_screen_position) (Vtemp_buffer_show_function, Vwindow_configuration_change_hook) (Vwindow_point_insertion_type, auto_window_vscroll_p) (mode_line_in_non_selected_windows, next_screen_context_lines) (window_min_height, window_min_width): Remove. (scroll_margin): Remove declaration. * w32term.c (syms_of_w32term): Update. (Vw32_capslock_is_shiftlock, Vw32_grab_focus_on_raise) (Vw32_recognize_altgr, Vw32_swap_mouse_buttons) (Vx_toolkit_scroll_bars, w32_num_mouse_buttons) (w32_use_visible_system_caret, x_underline_at_descent_line) (x_use_underline_position_properties): Remove. (Vcommand_line_args, Vsystem_name, extra_keyboard_modifiers): Remove declaration. * w32select.c (syms_of_w32select): Update. (Vnext_selection_coding_system, Vselection_coding_system): Remove. * w32proc.c (syms_of_ntproc): Update. (Vw32_downcase_file_names, Vw32_generate_fake_inodes) (Vw32_get_true_file_attributes, Vw32_quote_process_args) (Vw32_start_process_inherit_error_mode) (Vw32_start_process_share_console) (Vw32_start_process_show_window, w32_pipe_read_delay): Remove. (Vsystem_name): Remove declaration. * w32font.c (syms_of_w32font): Update. (Vw32_charset_info_alist): Remove. * w32fns.c (globals_of_w32fns, syms_of_w32fns): Update. (Vw32_alt_is_meta, Vw32_apps_modifier, Vw32_bdf_filename_alist) (Vw32_color_map, Vw32_enable_caps_lock, Vw32_enable_num_lock) (Vw32_enable_palette, Vw32_lwindow_modifier) (Vw32_pass_alt_to_system, Vw32_pass_lwindow_to_system) (Vw32_pass_rwindow_to_system, Vw32_phantom_key_code) (Vw32_rwindow_modifier, Vw32_scroll_lock_modifier) (Vx_cursor_fore_pixel, Vx_hourglass_pointer_shape) (Vx_max_tooltip_size, Vx_mode_pointer_shape) (Vx_no_window_manager, Vx_nontext_pointer_shape) (Vx_pixel_size_width_font_regexp, Vx_pointer_shape) (Vx_sensitive_text_pointer_shape) (Vx_window_horizontal_drag_shape, w32_ansi_code_page) (w32_enable_synthesized_fonts, w32_mouse_button_tolerance) (w32_mouse_move_interval) (w32_pass_extra_mouse_buttons_to_system) (w32_pass_multimedia_buttons_to_system, w32_quit_key) (w32_strict_fontnames, w32_strict_painting): Remove. (Vhourglass_delay, Vmenu_bar_mode, Vtool_bar_mode) (Vw32_recognize_altgr, Vwindow_system_version) (w32_num_mouse_buttons, w32_use_visible_system_caret): Remove declaration. * w32console.c (syms_of_ntterm): Update. (w32_use_full_screen_buffer): Remove. (Vtty_defined_color_alist): Remove declaration. * w16select.c (syms_of_win16select): Update. (Vnext_selection_coding_system, Vselection_coding_system): Remove. * undo.c (syms_of_undo): Update. (Vundo_outer_limit, Vundo_outer_limit_function) (undo_inhibit_record_point, undo_limit, undo_strong_limit): Remove. * textprop.c (syms_of_textprop): Update. (Vchar_property_alias_alist, Vdefault_text_properties) (Vinhibit_point_motion_hooks, Vtext_property_default_nonsticky): Remove. * terminal.c (syms_of_terminal): Update. (Vdelete_terminal_functions, Vring_bell_function): Remove. * term.c (syms_of_term): Update. (Vresume_tty_functions, Vsuspend_tty_functions) (no_redraw_on_reenter, system_uses_terminfo, visible_cursor): Remove. * syntax.c (syms_of_syntax): Update. (Vfind_word_boundary_function_table, multibyte_syntax_as_symbol) (open_paren_in_column_0_is_defun_start) (parse_sexp_ignore_comments, parse_sexp_lookup_properties) (words_include_escapes): Remove. * search.c (syms_of_search): Update. (Vinhibit_changing_match_data, Vsearch_spaces_regexp): Remove. * process.c (syms_of_process): Update. (Vprocess_adaptive_read_buffering, Vprocess_connection_type) (delete_exited_processes): Remove. * print.c (syms_of_print): Update. (Vfloat_output_format, Vprint_charset_text_property) (Vprint_circle, Vprint_continuous_numbering, Vprint_gensym) (Vprint_length, Vprint_level, Vprint_number_table) (Vstandard_output, print_escape_multibyte) (print_escape_newlines, print_escape_nonascii, print_quoted): Remove. * msdos.c (syms_of_msdos): Update. (Vdos_unsupported_char_glyph): Remove. (unibyte_display_via_language_environment): Remove declaration. * minibuf.c (syms_of_minibuf): Update. (Vcompletion_regexp_list, Vhistory_add_new_input) (Vhistory_length, Vminibuffer_completing_file_name) (Vminibuffer_completion_confirm) (Vminibuffer_completion_predicate, Vminibuffer_completion_table) (Vminibuffer_exit_hook, Vminibuffer_help_form) (Vminibuffer_history_position, Vminibuffer_history_variable) (Vminibuffer_prompt_properties, Vminibuffer_setup_hook) (Vread_buffer_function, Vread_expression_map) (completion_ignore_case, enable_recursive_minibuffers) (history_delete_duplicates, minibuffer_allow_text_properties) (minibuffer_auto_raise, read_buffer_completion_ignore_case): Remove. * marker.c (syms_of_marker): Update. (byte_debug_flag): Remove. * macros.c (syms_of_macros): Update. (Vexecuting_kbd_macro, executing_kbd_macro_index): Remove. * lread.c (syms_of_lread): Update. (Vafter_load_alist, Vbyte_boolean_vars) (Vbytecomp_version_regexp, Vcurrent_load_list) (Veval_buffer_list, Vload_file_name, Vload_file_rep_suffixes) (Vload_history, Vload_path, Vload_read_function) (Vload_source_file_function, Vload_suffixes, Vobarray) (Vold_style_backquotes, Vpreloaded_file_list, Vread_circle) (Vread_symbol_positions_list, Vread_with_symbol_positions) (Vsource_directory, Vstandard_input, Vuser_init_file, Vvalues) (force_load_messages, load_convert_to_unibyte) (load_dangerous_libraries, load_force_doc_strings) (load_in_progress): Remove. * keymap.c (syms_of_keymap): Update. (Vdefine_key_rebound_commands, Vemulation_mode_map_alists) (Vminibuffer_local_completion_map) (Vminibuffer_local_filename_completion_map) (Vminibuffer_local_filename_must_match_map) (Vminibuffer_local_map, Vminibuffer_local_must_match_map) (Vminibuffer_local_ns_map, Vminor_mode_map_alist) (Vminor_mode_overriding_map_alist, Vwhere_is_preferred_modifier): Remove. * keyboard.c (syms_of_keyboard): Update. (Vauto_save_timeout, Vcommand_error_function) (Vcommand_hook_internal, Vdeactivate_mark) (Vdeferred_action_function, Vdeferred_action_list) (Vdisable_point_adjustment, Vdouble_click_time) (Vecho_keystrokes, Venable_disabled_menus_and_buttons) (Vfunction_key_map, Vglobal_disable_point_adjustment) (Vhelp_char, Vhelp_event_list, Vhelp_form) (Vinput_method_function, Vinput_method_previous_message) (Vkey_translation_map, Vlast_event_frame) (Vlucid_menu_bar_dirty_flag, Vmenu_bar_final_items) (Vminibuffer_message_timeout, Voverriding_local_map) (Voverriding_local_map_menu_flag, Vpost_command_hook) (Vpre_command_hook, Vprefix_help_command) (Vsaved_region_selection, Vselect_active_regions) (Vshow_help_function, Vspecial_event_map, Vsuggest_key_bindings) (Vthis_command, Vthis_command_keys_shift_translated) (Vthis_original_command, Vthrow_on_input, Vtimer_idle_list) (Vtimer_list, Vtool_bar_separator_image_expression, Vtop_level) (Vtty_erase_char, Vunread_command_events) (Vunread_input_method_events, Vunread_post_input_method_events) (auto_save_interval, cannot_suspend, do_mouse_tracking) (double_click_fuzz, extra_keyboard_modifiers) (inhibit_local_menu_bar_menus, last_command_event) (last_input_event, last_nonmenu_event, menu_prompt_more_char) (menu_prompting, meta_prefix_char, num_input_keys) (num_nonmacro_input_events, polling_period, unread_command_char): Remove. * insdel.c (syms_of_insdel): Update. (Vcombine_after_change_calls, check_markers_debug_flag): Remove. * indent.c (syms_of_indent): Update. (indent_tabs_mode): Remove. * image.c (syms_of_image): Update. (Vimage_cache_eviction_delay, Vimage_types) (Vimagemagick_render_type, Vmax_image_size, Vx_bitmap_file_path) (cross_disabled_images): Remove. * fringe.c (syms_of_fringe): Update. (Vfringe_bitmaps, Voverflow_newline_into_fringe): Remove. * frame.c (syms_of_frame): Update. (Vdefault_frame_alist, Vdefault_frame_scroll_bars) (Vdelete_frame_functions, Vframe_alpha_lower_limit) (Vmake_pointer_invisible, Vmenu_bar_mode, Vmouse_highlight) (Vmouse_position_function, Vterminal_frame, Vtool_bar_mode) (Vx_resource_class, Vx_resource_name, focus_follows_mouse): Remove. * fontset.c (syms_of_fontset): Update. (Valternate_fontname_alist, Vfont_encoding_charset_alist) (Vfontset_alias_alist, Vignore_relative_composition) (Votf_script_alist, Vuse_default_ascent) (Vvertical_centering_font_regexp): Remove. * font.c (syms_of_font): Update. (Vfont_encoding_alist, Vfont_log, Vfont_slant_table) (Vfont_weight_table, Vfont_width_table): Remove. * fns.c (syms_of_fns): Update. (Vfeatures, use_dialog_box, use_file_dialog): Remove. * filelock.c (syms_of_filelock): Update. (Vtemporary_file_directory): Remove. * fileio.c (syms_of_fileio): Update. (Vafter_insert_file_functions, Vauto_save_include_big_deletions) (Vauto_save_list_file_name, Vauto_save_visited_file_name) (Vdefault_file_name_coding_system, Vfile_name_coding_system) (Vfile_name_handler_alist, Vinhibit_file_name_handlers) (Vinhibit_file_name_operation, Vset_auto_coding_function) (Vwrite_region_annotate_functions) (Vwrite_region_annotations_so_far) (Vwrite_region_post_annotation_function) (delete_by_moving_to_trash, write_region_inhibit_fsync): Remove. (Vw32_get_true_file_attributes): Remove declaration. * eval.c (syms_of_eval): Update. (Vdebug_ignored_errors, Vdebug_on_error, Vdebug_on_signal) (Vdebugger, Vinhibit_quit, Vmacro_declaration_function) (Vquit_flag, Vsignal_hook_function, Vstack_trace_on_error) (debug_on_next_call, debug_on_quit, debugger_may_continue) (max_lisp_eval_depth, max_specpdl_size): Remove. * emacs.c (syms_of_emacs): Update. (Vafter_init_time, Vbefore_init_time, Vcommand_line_args) (Vdynamic_library_alist, Vemacs_copyright, Vemacs_version) (Vinstallation_directory, Vinvocation_directory) (Vinvocation_name, Vkill_emacs_hook, Vpath_separator) (Vprevious_system_messages_locale, Vprevious_system_time_locale) (Vsystem_configuration, Vsystem_configuration_options) (Vsystem_messages_locale, Vsystem_time_locale, Vsystem_type) (inhibit_x_resources, noninteractive1): Remove. * editfns.c (syms_of_editfns): Update. (Vbuffer_access_fontified_property) (Vbuffer_access_fontify_functions, Vinhibit_field_text_motion) (Voperating_system_release, Vsystem_name, Vuser_full_name) (Vuser_login_name, Vuser_real_login_name): Remove. * dosfns.c (syms_of_dosfns): Update. (Vdos_display_scancodes, Vdos_version, Vdos_windows_version) (dos_codepage, dos_country_code, dos_decimal_point) (dos_hyper_key, dos_keyboard_layout, dos_keypad_mode) (dos_super_key, dos_timezone_offset): Remove. * doc.c (syms_of_doc): Update. (Vbuild_files, Vdoc_file_name): Remove. * dispnew.c (syms_of_display): Update. (Vglyph_table, Vinitial_window_system) (Vredisplay_preemption_period, Vstandard_display_table) (Vwindow_system_version, baud_rate, cursor_in_echo_area) (inverse_video, redisplay_dont_pause, visible_bell): Remove. * dired.c (syms_of_dired): Update. (Vcompletion_ignored_extensions): Remove. (Vw32_get_true_file_attributes): Remove declaration. * dbusbind.c (syms_of_dbusbind): Update. (Vdbus_debug, Vdbus_registered_buses) (Vdbus_registered_objects_table): Remove. * data.c (syms_of_data): Update. (Vmost_negative_fixnum, Vmost_positive_fixnum): Remove. * composite.c (syms_of_composite): Update. (Vauto_composition_function, Vauto_composition_mode) (Vcompose_chars_after_function, Vcomposition_function_table): Remove. * coding.c (syms_of_coding): Update. (Vcharset_revision_table, Vcoding_category_list) (Vcoding_system_alist, Vcoding_system_for_read) (Vcoding_system_for_write, Vcoding_system_list) (Vdefault_process_coding_system, Venable_character_translation) (Vfile_coding_system_alist, Vlast_code_conversion_error) (Vlast_coding_system_used, Vlatin_extra_code_table) (Vlocale_coding_system, Vnetwork_coding_system_alist) (Vprocess_coding_system_alist) (Vselect_safe_coding_system_function) (Vstandard_translation_table_for_decode) (Vstandard_translation_table_for_encode) (Vtranslation_table_for_input, coding_system_require_warning) (eol_mnemonic_dos, eol_mnemonic_mac, eol_mnemonic_undecided) (eol_mnemonic_unix, inherit_process_coding_system) (inhibit_eol_conversion, inhibit_iso_escape_detection) (inhibit_null_byte_detection): Remove. * cmds.c (syms_of_cmds): Update. (Vpost_self_insert_hook): Remove. * charset.c (syms_of_charset): Update. (Vcharset_list, Vcharset_map_path, Vcurrent_iso639_language) (inhibit_load_charset_map): Remove. * character.c (syms_of_character): Update. (Vauto_fill_chars, Vchar_direction_table, Vchar_script_table) (Vchar_width_table, Vprintable_chars) (Vscript_representative_chars, Vtranslation_table_vector) (Vunicode_category_table): Remove. * ccl.c (syms_of_ccl): Update. (Vcode_conversion_map_vector, Vfont_ccl_encoder_alist) (Vtranslation_hash_table_vector): Remove. * category.c (syms_of_category): Update. (Vword_combining_categories, Vword_separating_categories): Remove. * callproc.c (syms_of_callproc): Update. (Vconfigure_info_directory, Vdata_directory, Vdoc_directory) (Vexec_directory, Vexec_path, Vexec_suffixes) (Vinitial_environment, Vprocess_environment) (Vshared_game_score_directory, Vshell_file_name): Remove. * callint.c (syms_of_callint): Update. (Vcommand_debug_status, Vcommand_history, Vcurrent_prefix_arg) (Vmark_even_if_inactive, Vmouse_leave_buffer_hook): Remove. * bytecode.c (syms_of_bytecode): Update. (Vbyte_code_meter, byte_metering_on): Remove. * buffer.c (syms_of_buffer): Update. (Vafter_change_functions, Vbefore_change_functions) (Vchange_major_mode_hook, Vfirst_change_hook) (Vinhibit_read_only, Vkill_buffer_query_functions) (Vtransient_mark_mode, inhibit_modification_hooks): Remove. * alloc.c (syms_of_alloc): Update. (Vgc_cons_percentage, Vgc_elapsed, Vmemory_full) (Vmemory_signal_data, Vpost_gc_hook, Vpurify_flag) (cons_cells_consed, floats_consed, garbage_collection_messages) (gc_cons_threshold, gcs_done, intervals_consed) (misc_objects_consed, pure_bytes_used, string_chars_consed) (strings_consed, symbols_consed, vector_cells_consed): Remove. * lisp.h (DEFVAR_LISP, DEFVAR_LISP_NOPRO, DEFVAR_BOOL) (DEFVAR_INT): Assume global is in `globals'. * alloc.c (globals): Define.
author Tom Tromey <tromey@redhat.com>
date Tue, 18 Jan 2011 13:45:37 -0700
parents 417b1e4d63cd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16884
36babc489b0c Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents: 16826
diff changeset
1 /* Process support for GNU Emacs on the Microsoft W32 API.
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94839
diff changeset
2 Copyright (C) 1992, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 110994
diff changeset
3 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
5 This file is part of GNU Emacs.
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94839
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
8 it under the terms of the GNU General Public License as published by
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94839
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94839
diff changeset
10 (at your option) any later version.
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
15 GNU General Public License for more details.
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14036
diff changeset
17 You should have received a copy of the GNU General Public License
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94839
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94839
diff changeset
20 /*
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 Drew Bliss Oct 14, 1993
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 Adapted from alarm.c by Tim Fleehart
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 #include <stdio.h>
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 #include <stdlib.h>
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 #include <errno.h>
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 #include <io.h>
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
29 #include <fcntl.h>
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 #include <signal.h>
45089
3e9cb1567659 include sys/file.h.
Jason Rumney <jasonr@gnu.org>
parents: 45008
diff changeset
31 #include <sys/file.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 103813
diff changeset
32 #include <setjmp.h>
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
34 /* must include CRT headers *before* config.h */
42469
64341c22fb4c Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 40962
diff changeset
35 #include <config.h>
64341c22fb4c Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 40962
diff changeset
36
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
37 #undef signal
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
38 #undef wait
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
39 #undef spawnve
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
40 #undef select
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
41 #undef kill
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
42
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 #include <windows.h>
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
44 #ifdef __GNUC__
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
45 /* This definition is missing from mingw32 headers. */
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
46 extern BOOL WINAPI IsValidLocale (LCID, DWORD);
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
47 #endif
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
73091
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
49 #ifdef HAVE_LANGINFO_CODESET
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
50 #include <nl_types.h>
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
51 #include <langinfo.h>
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
52 #endif
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
53
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 #include "lisp.h"
90929
148920faca07 Include character.h
Jason Rumney <jasonr@gnu.org>
parents: 90921
diff changeset
55 #include "character.h"
16593
4ed80eda6fac Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents: 16588
diff changeset
56 #include "w32.h"
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
57 #include "w32heap.h"
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 #include "systime.h"
13931
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
59 #include "syswait.h"
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
60 #include "process.h"
37703
d0b43907dca5 Include syssignal.h, to avoid compiler warnings.
Eli Zaretskii <eliz@gnu.org>
parents: 37290
diff changeset
61 #include "syssignal.h"
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
62 #include "w32term.h"
95277
3df8e58fdc7f Include dispextern.h.
Eli Zaretskii <eliz@gnu.org>
parents: 95219
diff changeset
63 #include "dispextern.h" /* for xstrcasecmp */
100045
3ec2cc2d35c1 * w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents: 96893
diff changeset
64 #include "coding.h"
13931
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
65
63087
ba5fe07b9394 (RVA_TO_PTR): New macro.
Eli Zaretskii <eliz@gnu.org>
parents: 56729
diff changeset
66 #define RVA_TO_PTR(var,section,filedata) \
ba5fe07b9394 (RVA_TO_PTR): New macro.
Eli Zaretskii <eliz@gnu.org>
parents: 56729
diff changeset
67 ((void *)((section)->PointerToRawData \
ba5fe07b9394 (RVA_TO_PTR): New macro.
Eli Zaretskii <eliz@gnu.org>
parents: 56729
diff changeset
68 + ((DWORD)(var) - (section)->VirtualAddress) \
ba5fe07b9394 (RVA_TO_PTR): New macro.
Eli Zaretskii <eliz@gnu.org>
parents: 56729
diff changeset
69 + (filedata).file_base))
ba5fe07b9394 (RVA_TO_PTR): New macro.
Eli Zaretskii <eliz@gnu.org>
parents: 56729
diff changeset
70
80485
f1f27e9c15d7 (syms_of_ntproc): Change Vw32_get_true_file attributes
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
71 extern Lisp_Object Qlocal;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
72
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
73 Lisp_Object Qhigh, Qlow;
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
74
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
75 #ifdef EMACSDEBUG
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
76 void
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
77 _DebPrint (const char *fmt, ...)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
79 char buf[1024];
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 va_list args;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 va_start (args, fmt);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 vsprintf (buf, fmt, args);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 va_end (args);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 OutputDebugString (buf);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 #endif
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88
109160
f8660b83cdbf Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents: 109152
diff changeset
89 typedef void (_CALLBACK_ *signal_handler) (int);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 /* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 static signal_handler sig_handlers[NSIG];
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 /* Fake signal implementation to record the SIGCHLD handler. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
95 signal_handler
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
96 sys_signal (int sig, signal_handler handler)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 signal_handler old;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
99
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 if (sig != SIGCHLD)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 errno = EINVAL;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 return SIG_ERR;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 old = sig_handlers[sig];
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 sig_handlers[sig] = handler;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 return old;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
110 /* Defined in <process.h> which conflicts with the local copy */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
111 #define _P_NOWAIT 1
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
112
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
113 /* Child process management list. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
114 int child_proc_count = 0;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
115 child_process child_procs[ MAX_CHILDREN ];
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
116 child_process *dead_child = NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
117
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
118 static DWORD WINAPI reader_thread (void *arg);
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
119
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 /* Find an unused process slot. */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
121 child_process *
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 new_child (void)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 child_process *cp;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
125 DWORD id;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
126
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
127 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 if (!CHILD_ACTIVE (cp))
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
129 goto Initialise;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
130 if (child_proc_count == MAX_CHILDREN)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
131 return NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
132 cp = &child_procs[child_proc_count++];
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
133
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
134 Initialise:
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
135 memset (cp, 0, sizeof (*cp));
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
136 cp->fd = -1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
137 cp->pid = -1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
138 cp->procinfo.hProcess = NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
139 cp->status = STATUS_READ_ERROR;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
140
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
141 /* use manual reset event so that select() will function properly */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
142 cp->char_avail = CreateEvent (NULL, TRUE, FALSE, NULL);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
143 if (cp->char_avail)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
144 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
145 cp->char_consumed = CreateEvent (NULL, FALSE, FALSE, NULL);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
146 if (cp->char_consumed)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
147 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
148 cp->thrd = CreateThread (NULL, 1024, reader_thread, cp, 0, &id);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
149 if (cp->thrd)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
150 return cp;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
151 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
152 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
153 delete_child (cp);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
154 return NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
155 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
156
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
157 void
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
158 delete_child (child_process *cp)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
159 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
160 int i;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
161
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
162 /* Should not be deleting a child that is still needed. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
163 for (i = 0; i < MAXDESC; i++)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
164 if (fd_info[i].cp == cp)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
165 abort ();
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
166
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
167 if (!CHILD_ACTIVE (cp))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
168 return;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
169
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
170 /* reap thread if necessary */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
171 if (cp->thrd)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
172 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
173 DWORD rc;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
174
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
175 if (GetExitCodeThread (cp->thrd, &rc) && rc == STILL_ACTIVE)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
176 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
177 /* let the thread exit cleanly if possible */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
178 cp->status = STATUS_READ_ERROR;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
179 SetEvent (cp->char_consumed);
78726
bede1aa77f62 (delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents: 78260
diff changeset
180 #if 0
bede1aa77f62 (delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents: 78260
diff changeset
181 /* We used to forceably terminate the thread here, but it
bede1aa77f62 (delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents: 78260
diff changeset
182 is normally unnecessary, and in abnormal cases, the worst that
bede1aa77f62 (delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents: 78260
diff changeset
183 will happen is we have an extra idle thread hanging around
bede1aa77f62 (delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents: 78260
diff changeset
184 waiting for the zombie process. */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
185 if (WaitForSingleObject (cp->thrd, 1000) != WAIT_OBJECT_0)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
186 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
187 DebPrint (("delete_child.WaitForSingleObject (thread) failed "
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
188 "with %lu for fd %ld\n", GetLastError (), cp->fd));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
189 TerminateThread (cp->thrd, 0);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
190 }
78726
bede1aa77f62 (delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents: 78260
diff changeset
191 #endif
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
192 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
193 CloseHandle (cp->thrd);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
194 cp->thrd = NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
195 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
196 if (cp->char_avail)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
197 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
198 CloseHandle (cp->char_avail);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
199 cp->char_avail = NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
200 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
201 if (cp->char_consumed)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
202 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
203 CloseHandle (cp->char_consumed);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
204 cp->char_consumed = NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
205 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
206
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
207 /* update child_proc_count (highest numbered slot in use plus one) */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
208 if (cp == child_procs + child_proc_count - 1)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
209 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
210 for (i = child_proc_count-1; i >= 0; i--)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
211 if (CHILD_ACTIVE (&child_procs[i]))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
212 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
213 child_proc_count = i + 1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
214 break;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
215 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
216 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
217 if (i < 0)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
218 child_proc_count = 0;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 /* Find a child by pid. */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 static child_process *
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 find_child_pid (DWORD pid)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 child_process *cp;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
226
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
227 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 if (CHILD_ACTIVE (cp) && pid == cp->pid)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 return cp;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 return NULL;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
234 /* Thread proc for child process and socket reader threads. Each thread
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
235 is normally blocked until woken by select() to check for input by
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
236 reading one char. When the read completes, char_avail is signaled
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
237 to wake up the select emulator and the thread blocks itself again. */
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
238 static DWORD WINAPI
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 reader_thread (void *arg)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 child_process *cp;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
242
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 /* Our identity */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 cp = (child_process *)arg;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
245
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 /* We have to wait for the go-ahead before we can start */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
247 if (cp == NULL
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
248 || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
249 return 1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
250
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 for (;;)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
253 int rc;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
254
71901
7c2a2cf361cb (reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
255 if (fd_info[cp->fd].flags & FILE_LISTEN)
7c2a2cf361cb (reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
256 rc = _sys_wait_accept (cp->fd);
7c2a2cf361cb (reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
257 else
7c2a2cf361cb (reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents: 68651
diff changeset
258 rc = _sys_read_ahead (cp->fd);
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
259
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
260 /* The name char_avail is a misnomer - it really just means the
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
261 read-ahead has completed, whether successfully or not. */
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 if (!SetEvent (cp->char_avail))
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld\n",
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 GetLastError (), cp->fd));
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
266 return 1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
267 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
268
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
269 if (rc == STATUS_READ_ERROR)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
270 return 1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
271
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 /* If the read died, the child has died so let the thread die */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
273 if (rc == STATUS_READ_FAILED)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
275
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 /* Wait until our input is acknowledged before reading again */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 DebPrint (("reader_thread.WaitForSingleObject failed with "
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 "%lu for fd %ld\n", GetLastError (), cp->fd));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 break;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 return 0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
287 /* To avoid Emacs changing directory, we just record here the directory
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
288 the new process should start in. This is set just before calling
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
289 sys_spawnve, and is not generally valid at any other time. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
290 static char * process_dir;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
291
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
292 static BOOL
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
293 create_child (char *exe, char *cmdline, char *env, int is_gui_app,
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
294 int * pPid, child_process *cp)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 STARTUPINFO start;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 SECURITY_ATTRIBUTES sec_attrs;
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
298 #if 0
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299 SECURITY_DESCRIPTOR sec_desc;
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
300 #endif
23949
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
301 DWORD flags;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
302 char dir[ MAXPATHLEN ];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
303
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
304 if (cp == NULL) abort ();
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
305
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 memset (&start, 0, sizeof (start));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 start.cb = sizeof (start);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
308
13425
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
309 #ifdef HAVE_NTGUI
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
310 if (NILP (Vw32_start_process_show_window) && !is_gui_app)
16000
b5ecd5022991 (Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15419
diff changeset
311 start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
b5ecd5022991 (Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15419
diff changeset
312 else
b5ecd5022991 (Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15419
diff changeset
313 start.dwFlags = STARTF_USESTDHANDLES;
13425
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
314 start.wShowWindow = SW_HIDE;
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
315
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
316 start.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
317 start.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE);
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
318 start.hStdError = GetStdHandle (STD_ERROR_HANDLE);
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
319 #endif /* HAVE_NTGUI */
b6eacb7da9f6 [HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents: 12325
diff changeset
320
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
321 #if 0
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 /* Explicitly specify no security */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 if (!InitializeSecurityDescriptor (&sec_desc, SECURITY_DESCRIPTOR_REVISION))
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
324 goto EH_Fail;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 if (!SetSecurityDescriptorDacl (&sec_desc, TRUE, NULL, FALSE))
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
326 goto EH_Fail;
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
327 #endif
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 sec_attrs.nLength = sizeof (sec_attrs);
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
329 sec_attrs.lpSecurityDescriptor = NULL /* &sec_desc */;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 sec_attrs.bInheritHandle = FALSE;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
331
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
332 strcpy (dir, process_dir);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
333 unixtodos_filename (dir);
23949
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
334
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
335 flags = (!NILP (Vw32_start_process_share_console)
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
336 ? CREATE_NEW_PROCESS_GROUP
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
337 : CREATE_NEW_CONSOLE);
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
338 if (NILP (Vw32_start_process_inherit_error_mode))
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
339 flags |= CREATE_DEFAULT_ERROR_MODE;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 if (!CreateProcess (exe, cmdline, &sec_attrs, NULL, TRUE,
23949
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
341 flags, env, dir, &start, &cp->procinfo))
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
342 goto EH_Fail;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
343
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
344 cp->pid = (int) cp->procinfo.dwProcessId;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
345
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
346 /* Hack for Windows 95, which assigns large (ie negative) pids */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
347 if (cp->pid < 0)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
348 cp->pid = -cp->pid;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
349
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
350 /* pid must fit in a Lisp_Int */
55674
97c2d7314ac2 (create_child): Use INTMASK.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55648
diff changeset
351 cp->pid = cp->pid & INTMASK;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
352
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
353 *pPid = cp->pid;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
354
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355 return TRUE;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
356
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 EH_Fail:
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
358 DebPrint (("create_child.CreateProcess failed: %ld\n", GetLastError ()););
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 return FALSE;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
361
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
362 /* create_child doesn't know what emacs' file handle will be for waiting
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
363 on output from the child, so we need to make this additional call
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
364 to register the handle with the process
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365 This way the select emulator knows how to match file handles with
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 entries in child_procs. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
367 void
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 register_child (int pid, int fd)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 child_process *cp;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
371
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 cp = find_child_pid (pid);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 if (cp == NULL)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 DebPrint (("register_child unable to find pid %lu\n", pid));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 return;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
378
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 #ifdef FULL_DEBUG
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 DebPrint (("register_child registered fd %d with pid %lu\n", fd, pid));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 #endif
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
382
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 cp->fd = fd;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
384
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
385 /* thread is initially blocked until select is called; set status so
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
386 that select will release thread */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
387 cp->status = STATUS_READ_ACKNOWLEDGED;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
389 /* attach child_process to fd_info */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
390 if (fd_info[fd].cp != NULL)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
392 DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
393 abort ();
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
395
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
396 fd_info[fd].cp = cp;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 /* When a process dies its pipe will break so the reader thread will
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 signal failure to the select emulator.
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 The select emulator then calls this routine to clean up.
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 Since the thread signaled failure we can assume it is exiting. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
403 static void
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
404 reap_subprocess (child_process *cp)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
406 if (cp->procinfo.hProcess)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
408 /* Reap the process */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
409 #ifdef FULL_DEBUG
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
410 /* Process should have already died before we are called. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
411 if (WaitForSingleObject (cp->procinfo.hProcess, 0) != WAIT_OBJECT_0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
412 DebPrint (("reap_subprocess: child fpr fd %d has not died yet!", cp->fd));
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
413 #endif
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
414 CloseHandle (cp->procinfo.hProcess);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
415 cp->procinfo.hProcess = NULL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
416 CloseHandle (cp->procinfo.hThread);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
417 cp->procinfo.hThread = NULL;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
419
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
420 /* For asynchronous children, the child_proc resources will be freed
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
421 when the last pipe read descriptor is closed; for synchronous
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
422 children, we must explicitly free the resources now because
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
423 register_child has not been called. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
424 if (cp->fd == -1)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
425 delete_child (cp);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 /* Wait for any of our existing child processes to die
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 When it does, close its handle
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 Return the pid and fill in the status if non-NULL. */
11388
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
431
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
432 int
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
433 sys_wait (int *status)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 DWORD active, retval;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 int nh;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
437 int pid;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 child_process *cp, *cps[MAX_CHILDREN];
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 HANDLE wait_hnd[MAX_CHILDREN];
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
440
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 nh = 0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 if (dead_child != NULL)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 /* We want to wait for a specific child */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
445 wait_hnd[nh] = dead_child->procinfo.hProcess;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 cps[nh] = dead_child;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
447 if (!wait_hnd[nh]) abort ();
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 nh++;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
449 active = 0;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
450 goto get_result;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 else
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 {
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
454 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
455 /* some child_procs might be sockets; ignore them */
73664
a525ba4c658b * w32proc.c: (sys_wait) Only wait for processes with fd<0.
Chong Yidong <cyd@stupidchicken.com>
parents: 73091
diff changeset
456 if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess
a525ba4c658b * w32proc.c: (sys_wait) Only wait for processes with fd<0.
Chong Yidong <cyd@stupidchicken.com>
parents: 73091
diff changeset
457 && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0))
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
459 wait_hnd[nh] = cp->procinfo.hProcess;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 cps[nh] = cp;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 nh++;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
464
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 if (nh == 0)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 /* Nothing to wait on, so fail */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 errno = ECHILD;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
469 return -1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
471
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
472 do
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
473 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
474 /* Check for quit about once a second. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
475 QUIT;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
476 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, 1000);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
477 } while (active == WAIT_TIMEOUT);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
478
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 if (active == WAIT_FAILED)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 errno = EBADF;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 return -1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
484 else if (active >= WAIT_OBJECT_0
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
485 && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 active -= WAIT_OBJECT_0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
489 else if (active >= WAIT_ABANDONED_0
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
490 && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 active -= WAIT_ABANDONED_0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
494 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
495 abort ();
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
496
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
497 get_result:
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 if (!GetExitCodeProcess (wait_hnd[active], &retval))
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 DebPrint (("Wait.GetExitCodeProcess failed with %lu\n",
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 GetLastError ()));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 retval = 1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 if (retval == STILL_ACTIVE)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 /* Should never happen */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 DebPrint (("Wait.WaitForMultipleObjects returned an active process\n"));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 errno = EINVAL;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 return -1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 }
12325
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
511
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
512 /* Massage the exit code from the process to match the format expected
14036
621a575db6f7 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13931
diff changeset
513 by the WIFSTOPPED et al macros in syswait.h. Only WIFSIGNALED and
12325
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
514 WIFEXITED are supported; WIFSTOPPED doesn't make sense under NT. */
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
515
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
516 if (retval == STATUS_CONTROL_C_EXIT)
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
517 retval = SIGINT;
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
518 else
aa6fc4e97a28 (win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents: 12239
diff changeset
519 retval <<= 8;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
520
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 cp = cps[active];
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
522 pid = cp->pid;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
523 #ifdef FULL_DEBUG
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
524 DebPrint (("Wait signaled with process pid %d\n", cp->pid));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
525 #endif
11388
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
526
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 if (status)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 {
11388
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
529 *status = retval;
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
530 }
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
531 else if (synch_process_alive)
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
532 {
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
533 synch_process_alive = 0;
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
534
13931
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
535 /* Report the status of the synchronous process. */
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
536 if (WIFEXITED (retval))
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
537 synch_process_retcode = WRETCODE (retval);
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
538 else if (WIFSIGNALED (retval))
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
539 {
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
540 int code = WTERMSIG (retval);
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
541 char *signame;
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
542
26526
b7438760079b * callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents: 26088
diff changeset
543 synchronize_system_messages_locale ();
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
544 signame = strsignal (code);
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 25646
diff changeset
545
13931
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
546 if (signame == 0)
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
547 signame = "unknown";
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
548
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
549 synch_process_death = signame;
c80fb27c183b (win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents: 13425
diff changeset
550 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
551
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
552 reap_subprocess (cp);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
554
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
555 reap_subprocess (cp);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
556
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
557 return pid;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559
78168
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
560 /* Old versions of w32api headers don't have separate 32-bit and
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
561 64-bit defines, but the one they have matches the 32-bit variety. */
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
562 #ifndef IMAGE_NT_OPTIONAL_HDR32_MAGIC
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
563 # define IMAGE_NT_OPTIONAL_HDR32_MAGIC IMAGE_NT_OPTIONAL_HDR_MAGIC
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
564 # define IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
565 #endif
5d5dea23e4fd (IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents: 78164
diff changeset
566
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
567 static void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
568 w32_executable_type (char * filename,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
569 int * is_dos_app,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
570 int * is_cygnus_app,
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
571 int * is_gui_app)
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
572 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
573 file_data executable;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
574 char * p;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
575
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
576 /* Default values in case we can't tell for sure. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
577 *is_dos_app = FALSE;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
578 *is_cygnus_app = FALSE;
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
579 *is_gui_app = FALSE;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
580
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
581 if (!open_input_file (&executable, filename))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
582 return;
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
583
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
584 p = strrchr (filename, '.');
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
585
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
586 /* We can only identify DOS .com programs from the extension. */
95219
72c67a7befd5 * dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents: 94963
diff changeset
587 if (p && xstrcasecmp (p, ".com") == 0)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
588 *is_dos_app = TRUE;
95219
72c67a7befd5 * dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents: 94963
diff changeset
589 else if (p && (xstrcasecmp (p, ".bat") == 0
72c67a7befd5 * dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents: 94963
diff changeset
590 || xstrcasecmp (p, ".cmd") == 0))
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
591 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
592 /* A DOS shell script - it appears that CreateProcess is happy to
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
593 accept this (somewhat surprisingly); presumably it looks at
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
594 COMSPEC to determine what executable to actually invoke.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
595 Therefore, we have to do the same here as well. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
596 /* Actually, I think it uses the program association for that
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
597 extension, which is defined in the registry. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
598 p = egetenv ("COMSPEC");
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
599 if (p)
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
600 w32_executable_type (p, is_dos_app, is_cygnus_app, is_gui_app);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
601 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
602 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
603 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
604 /* Look for DOS .exe signature - if found, we must also check that
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
605 it isn't really a 16- or 32-bit Windows exe, since both formats
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
606 start with a DOS program stub. Note that 16-bit Windows
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
607 executables use the OS/2 1.x format. */
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
608
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
609 IMAGE_DOS_HEADER * dos_header;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
610 IMAGE_NT_HEADERS * nt_header;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
611
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
612 dos_header = (PIMAGE_DOS_HEADER) executable.file_base;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
613 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
614 goto unwind;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
615
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
616 nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
617
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
618 if ((char *) nt_header > (char *) dos_header + executable.size)
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
619 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
620 /* Some dos headers (pkunzip) have bogus e_lfanew fields. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
621 *is_dos_app = TRUE;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
622 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
623 else if (nt_header->Signature != IMAGE_NT_SIGNATURE
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
624 && LOWORD (nt_header->Signature) != IMAGE_OS2_SIGNATURE)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
625 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
626 *is_dos_app = TRUE;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
627 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
628 else if (nt_header->Signature == IMAGE_NT_SIGNATURE)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
629 {
78164
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
630 IMAGE_DATA_DIRECTORY *data_dir = NULL;
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
631 if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
632 {
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
633 /* Ensure we are using the 32 bit structure. */
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
634 IMAGE_OPTIONAL_HEADER32 *opt
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
635 = (IMAGE_OPTIONAL_HEADER32*) &(nt_header->OptionalHeader);
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
636 data_dir = opt->DataDirectory;
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
637 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
638 }
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
639 /* MingW 3.12 has the required 64 bit structs, but in case older
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
640 versions don't, only check 64 bit exes if we know how. */
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
641 #ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
642 else if (nt_header->OptionalHeader.Magic
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
643 == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
644 {
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
645 IMAGE_OPTIONAL_HEADER64 *opt
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
646 = (IMAGE_OPTIONAL_HEADER64*) &(nt_header->OptionalHeader);
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
647 data_dir = opt->DataDirectory;
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
648 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
649 }
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
650 #endif
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
651 if (data_dir)
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
652 {
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
653 /* Look for cygwin.dll in DLL import list. */
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
654 IMAGE_DATA_DIRECTORY import_dir =
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
655 data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
656 IMAGE_IMPORT_DESCRIPTOR * imports;
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
657 IMAGE_SECTION_HEADER * section;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
658
78164
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
659 section = rva_to_section (import_dir.VirtualAddress, nt_header);
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
660 imports = RVA_TO_PTR (import_dir.VirtualAddress, section,
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
661 executable);
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
662
78164
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
663 for ( ; imports->Name; imports++)
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
664 {
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
665 char * dllname = RVA_TO_PTR (imports->Name, section,
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
666 executable);
100062
d4660dbaa550 * w32proc.c (Fw32_get_locale_info): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 100045
diff changeset
667
78164
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
668 /* The exact name of the cygwin dll has changed with
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
669 various releases, but hopefully this will be reasonably
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
670 future proof. */
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
671 if (strncmp (dllname, "cygwin", 6) == 0)
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
672 {
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
673 *is_cygnus_app = TRUE;
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
674 break;
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
675 }
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
676 }
d9f9dda7474c (w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents: 75348
diff changeset
677 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
678 }
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
679 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
680
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
681 unwind:
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
682 close_file_data (&executable);
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
683 }
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
684
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
685 static int
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
686 compare_env (const void *strp1, const void *strp2)
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
687 {
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
688 const char *str1 = *(const char **)strp1, *str2 = *(const char **)strp2;
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
689
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
690 while (*str1 && *str2 && *str1 != '=' && *str2 != '=')
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
691 {
31354
547138676a74 (compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents: 31115
diff changeset
692 /* Sort order in command.com/cmd.exe is based on uppercasing
547138676a74 (compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents: 31115
diff changeset
693 names, so do the same here. */
547138676a74 (compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents: 31115
diff changeset
694 if (toupper (*str1) > toupper (*str2))
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
695 return 1;
31354
547138676a74 (compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents: 31115
diff changeset
696 else if (toupper (*str1) < toupper (*str2))
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
697 return -1;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
698 str1++, str2++;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
699 }
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
700
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
701 if (*str1 == '=' && *str2 == '=')
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
702 return 0;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
703 else if (*str1 == '=')
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
704 return -1;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
705 else
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
706 return 1;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
707 }
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
708
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
709 static void
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
710 merge_and_sort_env (char **envp1, char **envp2, char **new_envp)
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
711 {
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
712 char **optr, **nptr;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
713 int num;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
714
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
715 nptr = new_envp;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
716 optr = envp1;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
717 while (*optr)
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
718 *nptr++ = *optr++;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
719 num = optr - envp1;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
720
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
721 optr = envp2;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
722 while (*optr)
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
723 *nptr++ = *optr++;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
724 num += optr - envp2;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
725
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
726 qsort (new_envp, num, sizeof (char *), compare_env);
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
727
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
728 *nptr = NULL;
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
729 }
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 /* When a new child process is created we need to register it in our list,
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 so intercept spawn requests. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
733 int
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
734 sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 {
12239
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
736 Lisp_Object program, full;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 char *cmdline, *env, *parg, **targ;
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
738 int arglen, numenv;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
739 int pid;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
740 child_process *cp;
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
741 int is_dos_app, is_cygnus_app, is_gui_app;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
742 int do_quoting = 0;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
743 char escape_char;
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
744 /* We pass our process ID to our children by setting up an environment
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
745 variable in their environment. */
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
746 char ppid_env_var_buffer[64];
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
747 char *extra_env[] = {ppid_env_var_buffer, NULL};
79490
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
748 /* These are the characters that cause an argument to need quoting.
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
749 Arguments with whitespace characters need quoting to prevent the
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
750 argument being split into two or more. Arguments with wildcards
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
751 are also quoted, for consistency with posix platforms, where wildcards
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
752 are not expanded if we run the program directly without a shell.
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
753 Some extra whitespace characters need quoting in Cygwin programs,
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
754 so this list is conditionally modified below. */
217ec3ada789 (sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents: 78726
diff changeset
755 char *sepchars = " \t*?";
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
756
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
757 /* We don't care about the other modes */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
758 if (mode != _P_NOWAIT)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
759 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
760 errno = EINVAL;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
761 return -1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
762 }
12239
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
763
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
764 /* Handle executable names without an executable suffix. */
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
765 program = make_string (cmdname, strlen (cmdname));
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
766 if (NILP (Ffile_executable_p (program)))
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
767 {
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
768 struct gcpro gcpro1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
769
12239
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
770 full = Qnil;
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
771 GCPRO1 (program);
45008
07245ba4ebcc (sys_spawnve): Update call to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44928
diff changeset
772 openp (Vexec_path, program, Vexec_suffixes, &full, make_number (X_OK));
12239
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
773 UNGCPRO;
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
774 if (NILP (full))
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
775 {
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
776 errno = EINVAL;
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
777 return -1;
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
778 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
779 program = full;
12239
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
780 }
ff7738cdbd99 (win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents: 12183
diff changeset
781
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
782 /* make sure argv[0] and cmdname are both in DOS format */
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45089
diff changeset
783 cmdname = SDATA (program);
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
784 unixtodos_filename (cmdname);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
785 argv[0] = cmdname;
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
786
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
787 /* Determine whether program is a 16-bit DOS executable, or a w32
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
788 executable that is implicitly linked to the Cygnus dll (implying it
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
789 was compiled with the Cygnus GNU toolchain and hence relies on
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
790 cygwin.dll to parse the command line - we use this to decide how to
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
791 escape quote chars in command line args that must be quoted).
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
792
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
793 Also determine whether it is a GUI app, so that we don't hide its
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
794 initial window unless specifically requested. */
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
795 w32_executable_type (cmdname, &is_dos_app, &is_cygnus_app, &is_gui_app);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
796
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
797 /* On Windows 95, if cmdname is a DOS app, we invoke a helper
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
798 application to start it by specifying the helper app as cmdname,
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
799 while leaving the real app name as argv[0]. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
800 if (is_dos_app)
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
801 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
802 cmdname = alloca (MAXPATHLEN);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
803 if (egetenv ("CMDPROXY"))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
804 strcpy (cmdname, egetenv ("CMDPROXY"));
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
805 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
806 {
46370
40db0673e6f0 Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents: 45089
diff changeset
807 strcpy (cmdname, SDATA (Vinvocation_directory));
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
808 strcat (cmdname, "cmdproxy.exe");
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
809 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
810 unixtodos_filename (cmdname);
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
811 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
812
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 /* we have to do some conjuring here to put argv and envp into the
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 form CreateProcess wants... argv needs to be a space separated/null
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
815 terminated list of parameters, and envp is a null
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 separated/double-null terminated list of parameters.
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
817
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
818 Additionally, zero-length args and args containing whitespace or
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
819 quote chars need to be wrapped in double quotes - for this to work,
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
820 embedded quotes need to be escaped as well. The aim is to ensure
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
821 the child process reconstructs the argv array we start with
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
822 exactly, so we treat quotes at the beginning and end of arguments
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
823 as embedded quotes.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
824
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
825 The w32 GNU-based library from Cygnus doubles quotes to escape
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
826 them, while MSVC uses backslash for escaping. (Actually the MSVC
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
827 startup code does attempt to recognise doubled quotes and accept
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
828 them, but gets it wrong and ends up requiring three quotes to get a
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
829 single embedded quote!) So by default we decide whether to use
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
830 quote or backslash as the escape character based on whether the
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
831 binary is apparently a Cygnus compiled app.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
832
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
833 Note that using backslash to escape embedded quotes requires
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
834 additional special handling if an embedded quote is already
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
835 preceeded by backslash, or if an arg requiring quoting ends with
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
836 backslash. In such cases, the run of escape characters needs to be
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
837 doubled. For consistency, we apply this special handling as long
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
838 as the escape character is not quote.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
839
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
840 Since we have no idea how large argv and envp are likely to be we
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
841 figure out list lengths on the fly and allocate them. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
842
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
843 if (!NILP (Vw32_quote_process_args))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
844 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
845 do_quoting = 1;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
846 /* Override escape char by binding w32-quote-process-args to
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
847 desired character, or use t for auto-selection. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
848 if (INTEGERP (Vw32_quote_process_args))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
849 escape_char = XINT (Vw32_quote_process_args);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
850 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
851 escape_char = is_cygnus_app ? '"' : '\\';
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
852 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
853
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
854 /* Cygwin apps needs quoting a bit more often. */
37290
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
855 if (escape_char == '"')
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
856 sepchars = "\r\n\t\f '";
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
857
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 /* do argv... */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 arglen = 0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 targ = argv;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 while (*targ)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
863 char * p = *targ;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
864 int need_quotes = 0;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
865 int escape_char_run = 0;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
866
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
867 if (*p == 0)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
868 need_quotes = 1;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
869 for ( ; *p; p++)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
870 {
37290
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
871 if (escape_char == '"' && *p == '\\')
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
872 /* If it's a Cygwin app, \ needs to be escaped. */
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
873 arglen++;
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
874 else if (*p == '"')
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
875 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
876 /* allow for embedded quotes to be escaped */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
877 arglen++;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
878 need_quotes = 1;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
879 /* handle the case where the embedded quote is already escaped */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
880 if (escape_char_run > 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
881 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
882 /* To preserve the arg exactly, we need to double the
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
883 preceding escape characters (plus adding one to
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
884 escape the quote character itself). */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
885 arglen += escape_char_run;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
886 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
887 }
37290
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
888 else if (strchr (sepchars, *p) != NULL)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
889 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
890 need_quotes = 1;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
891 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
892
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
893 if (*p == escape_char && escape_char != '"')
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
894 escape_char_run++;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
895 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
896 escape_char_run = 0;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
897 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
898 if (need_quotes)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
899 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
900 arglen += 2;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
901 /* handle the case where the arg ends with an escape char - we
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
902 must not let the enclosing quote be escaped. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
903 if (escape_char_run > 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
904 arglen += escape_char_run;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
905 }
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 arglen += strlen (*targ++) + 1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
908 cmdline = alloca (arglen);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 targ = argv;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 parg = cmdline;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 while (*targ)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
913 char * p = *targ;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
914 int need_quotes = 0;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
915
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
916 if (*p == 0)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
917 need_quotes = 1;
15201
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
918
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
919 if (do_quoting)
15201
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
920 {
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
921 for ( ; *p; p++)
37290
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
922 if ((strchr (sepchars, *p) != NULL) || *p == '"')
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
923 need_quotes = 1;
15201
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
924 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
925 if (need_quotes)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
926 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
927 int escape_char_run = 0;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
928 char * first;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
929 char * last;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
930
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
931 p = *targ;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
932 first = p;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
933 last = p + strlen (p) - 1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
934 *parg++ = '"';
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
935 #if 0
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
936 /* This version does not escape quotes if they occur at the
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
937 beginning or end of the arg - this could lead to incorrect
96376
c3309dba6542 American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 96361
diff changeset
938 behavior when the arg itself represents a command line
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
939 containing quoted args. I believe this was originally done
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
940 as a hack to make some things work, before
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
941 `w32-quote-process-args' was added. */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
942 while (*p)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
943 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
944 if (*p == '"' && p > first && p < last)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
945 *parg++ = escape_char; /* escape embedded quotes */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
946 *parg++ = *p++;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
947 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
948 #else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
949 for ( ; *p; p++)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
950 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
951 if (*p == '"')
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
952 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
953 /* double preceding escape chars if any */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
954 while (escape_char_run > 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
955 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
956 *parg++ = escape_char;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
957 escape_char_run--;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
958 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
959 /* escape all quote chars, even at beginning or end */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
960 *parg++ = escape_char;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
961 }
37290
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
962 else if (escape_char == '"' && *p == '\\')
6e6e46d239df (sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents: 33694
diff changeset
963 *parg++ = '\\';
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
964 *parg++ = *p;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
965
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
966 if (*p == escape_char && escape_char != '"')
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
967 escape_char_run++;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
968 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
969 escape_char_run = 0;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
970 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
971 /* double escape chars before enclosing quote */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
972 while (escape_char_run > 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
973 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
974 *parg++ = escape_char;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
975 escape_char_run--;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
976 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
977 #endif
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
978 *parg++ = '"';
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
979 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
980 else
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
981 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
982 strcpy (parg, *targ);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
983 parg += strlen (*targ);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
984 }
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 *parg++ = ' ';
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
986 targ++;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 *--parg = '\0';
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
989
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 /* and envp... */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 arglen = 1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 targ = envp;
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
993 numenv = 1; /* for end null */
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 while (*targ)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 arglen += strlen (*targ++) + 1;
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
997 numenv++;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 }
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
999 /* extra env vars... */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1000 sprintf (ppid_env_var_buffer, "EM_PARENT_PROCESS_ID=%d",
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 GetCurrentProcessId ());
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 arglen += strlen (ppid_env_var_buffer) + 1;
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1003 numenv++;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004
16826
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1005 /* merge env passed in and extra env into one, and sort it. */
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1006 targ = (char **) alloca (numenv * sizeof (char *));
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1007 merge_and_sort_env (envp, extra_env, targ);
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1008
e7ad34b65d8e (compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1009 /* concatenate env entries. */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1010 env = alloca (arglen);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 parg = env;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 while (*targ)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 strcpy (parg, *targ);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 parg += strlen (*targ++);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 *parg++ = '\0';
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 *parg++ = '\0';
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 *parg = '\0';
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1020
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1021 cp = new_child ();
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1022 if (cp == NULL)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1024 errno = EAGAIN;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1025 return -1;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1027
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1028 /* Now create the process. */
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
1029 if (!create_child (cmdname, cmdline, env, is_gui_app, &pid, cp))
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1030 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1031 delete_child (cp);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1032 errno = ENOEXEC;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1033 return -1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1034 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1035
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1036 return pid;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 /* Emulate the select call
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 Wait for available input on any of the given rfds, or timeout if
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 a timeout is given and no input is detected
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1042 wfds and efds are not supported and must be NULL.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1043
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1044 For simplicity, we detect the death of child processes here and
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1045 synchronously call the SIGCHLD handler. Since it is possible for
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1046 children to be created without a corresponding pipe handle from which
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1047 to read output, we wait separately on the process handles as well as
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1048 the char_avail events for each process pipe. We only call
22079
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1049 wait/reap_process when the process actually terminates.
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1050
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1051 To reduce the number of places in which Emacs can be hung such that
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1052 C-g is not able to interrupt it, we always wait on interrupt_handle
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
1053 (which is signaled by the input thread when C-g is detected). If we
22079
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1054 detect that we were woken up by C-g, we return -1 with errno set to
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1055 EINTR as on Unix. */
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 /* From ntterm.c */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 extern HANDLE keyboard_handle;
22079
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1059
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1060 /* From w32xfns.c */
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1061 extern HANDLE interrupt_handle;
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1062
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 /* From process.c */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 extern int proc_buffered_char[];
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1066 int
11388
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
1067 sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
1068 EMACS_TIME *timeout)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 SELECT_TYPE orfds;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1071 DWORD timeout_ms, start_time;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1072 int i, nh, nc, nr;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 DWORD active;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1074 child_process *cp, *cps[MAX_CHILDREN];
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1075 HANDLE wait_hnd[MAXDESC + MAX_CHILDREN];
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1076 int fdindex[MAXDESC]; /* mapping from wait handles back to descriptors */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1077
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1078 timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFINITE;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1079
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 /* If the descriptor sets are NULL but timeout isn't, then just Sleep. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1081 if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1083 Sleep (timeout_ms);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 return 0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 /* Otherwise, we only handle rfds, so fail otherwise. */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 if (rfds == NULL || wfds != NULL || efds != NULL)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 errno = EINVAL;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 return -1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1093
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 orfds = *rfds;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 FD_ZERO (rfds);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 nr = 0;
22079
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1097
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1098 /* Always wait on interrupt_handle, to detect C-g (quit). */
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1099 wait_hnd[0] = interrupt_handle;
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1100 fdindex[0] = -1;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1101
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1102 /* Build a list of pipe handles to wait on. */
22079
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1103 nh = 1;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 for (i = 0; i < nfds; i++)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 if (FD_ISSET (i, &orfds))
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 if (i == 0)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1109 if (keyboard_handle)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1110 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1111 /* Handle stdin specially */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1112 wait_hnd[nh] = keyboard_handle;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1113 fdindex[nh] = i;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1114 nh++;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1115 }
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 /* Check for any emacs-generated input in the queue since
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 it won't be detected in the wait */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 if (detect_input_pending ())
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 FD_SET (i, rfds);
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1122 return 1;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 else
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1127 /* Child process and socket input */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1128 cp = fd_info[i].cp;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 if (cp)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1131 int current_status = cp->status;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1132
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1133 if (current_status == STATUS_READ_ACKNOWLEDGED)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1134 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1135 /* Tell reader thread which file handle to use. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1136 cp->fd = i;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1137 /* Wake up the reader thread for this process */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1138 cp->status = STATUS_READ_READY;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1139 if (!SetEvent (cp->char_consumed))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1140 DebPrint (("nt_select.SetEvent failed with "
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1141 "%lu for fd %ld\n", GetLastError (), i));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1142 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1143
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1144 #ifdef CHECK_INTERLOCK
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1145 /* slightly crude cross-checking of interlock between threads */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1146
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1147 current_status = cp->status;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1148 if (WaitForSingleObject (cp->char_avail, 0) == WAIT_OBJECT_0)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1149 {
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
1150 /* char_avail has been signaled, so status (which may
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1151 have changed) should indicate read has completed
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1152 but has not been acknowledged. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1153 current_status = cp->status;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1154 if (current_status != STATUS_READ_SUCCEEDED
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1155 && current_status != STATUS_READ_FAILED)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1156 DebPrint (("char_avail set, but read not completed: status %d\n",
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1157 current_status));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1158 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1159 else
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1160 {
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
1161 /* char_avail has not been signaled, so status should
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1162 indicate that read is in progress; small possibility
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
1163 that read has completed but event wasn't yet signaled
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1164 when we tested it (because a context switch occurred
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1165 or if running on separate CPUs). */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1166 if (current_status != STATUS_READ_READY
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1167 && current_status != STATUS_READ_IN_PROGRESS
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1168 && current_status != STATUS_READ_SUCCEEDED
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1169 && current_status != STATUS_READ_FAILED)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1170 DebPrint (("char_avail reset, but read status is bad: %d\n",
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1171 current_status));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1172 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1173 #endif
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1174 wait_hnd[nh] = cp->char_avail;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1175 fdindex[nh] = i;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1176 if (!wait_hnd[nh]) abort ();
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1177 nh++;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 #ifdef FULL_DEBUG
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 DebPrint (("select waiting on child %d fd %d\n",
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 cp-child_procs, i));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 #endif
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 else
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1185 /* Unable to find something to wait on for this fd, skip */
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1186
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1187 /* Note that this is not a fatal error, and can in fact
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1188 happen in unusual circumstances. Specifically, if
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1189 sys_spawnve fails, eg. because the program doesn't
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1190 exist, and debug-on-error is t so Fsignal invokes a
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1191 nested input loop, then the process output pipe is
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1192 still included in input_wait_mask with no child_proc
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1193 associated with it. (It is removed when the debugger
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1194 exits the nested input loop and the error is thrown.) */
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1195
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1196 DebPrint (("sys_select: fd %ld is invalid! ignoring\n", i));
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1200
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1201 count_children:
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1202 /* Add handles of child processes. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1203 nc = 0;
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1204 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--)
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1205 /* Some child_procs might be sockets; ignore them. Also some
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1206 children may have died already, but we haven't finished reading
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1207 the process output; ignore them too. */
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1208 if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1209 && (cp->fd < 0
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1210 || (fd_info[cp->fd].flags & FILE_SEND_SIGCHLD) == 0
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1211 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0)
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1212 )
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1213 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1214 wait_hnd[nh + nc] = cp->procinfo.hProcess;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1215 cps[nc] = cp;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1216 nc++;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1217 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1218
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 /* Nothing to look for, so we didn't find anything */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1220 if (nh + nc == 0)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 {
11388
96fa39ad9403 (win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents: 9907
diff changeset
1222 if (timeout)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1223 Sleep (timeout_ms);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 return 0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1226
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1227 start_time = GetTickCount ();
24915
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1228
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
1229 /* Wait for input or child death to be signaled. If user input is
24915
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1230 allowed, then also accept window messages. */
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1231 if (FD_ISSET (0, &orfds))
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1232 active = MsgWaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms,
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1233 QS_ALLINPUT);
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1234 else
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1235 active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms);
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1236
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 if (active == WAIT_FAILED)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n",
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1240 nh + nc, timeout_ms, GetLastError ()));
56729
e6e0caa7ec87 Rename wait_reading_process_input to wait_reading_process_output.
Kim F. Storm <storm@cua.dk>
parents: 55674
diff changeset
1241 /* don't return EBADF - this causes wait_reading_process_output to
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1242 abort; WAIT_FAILED is returned when single-stepping under
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1243 Windows 95 after switching thread focus in debugger, and
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1244 possibly at other times. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1245 errno = EINTR;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 return -1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 else if (active == WAIT_TIMEOUT)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 return 0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1252 else if (active >= WAIT_OBJECT_0
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1253 && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 active -= WAIT_OBJECT_0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1257 else if (active >= WAIT_ABANDONED_0
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1258 && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 active -= WAIT_ABANDONED_0;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1262 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1263 abort ();
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1264
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1265 /* Loop over all handles after active (now officially documented as
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 95277
diff changeset
1266 being the first signaled handle in the array). We do this to
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1267 ensure fairness, so that all channels with data available will be
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1268 processed - otherwise higher numbered channels could be starved. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1269 do
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 {
24915
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1271 if (active == nh + nc)
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1272 {
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1273 /* There are messages in the lisp thread's queue; we must
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1274 drain the queue now to ensure they are processed promptly,
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1275 because if we don't do so, we will not be woken again until
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1276 further messages arrive.
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1277
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1278 NB. If ever we allow window message procedures to callback
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1279 into lisp, we will need to ensure messages are dispatched
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1280 at a safe time for lisp code to be run (*), and we may also
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1281 want to provide some hooks in the dispatch loop to cater
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1282 for modeless dialogs created by lisp (ie. to register
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1283 window handles to pass to IsDialogMessage).
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1284
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1285 (*) Note that MsgWaitForMultipleObjects above is an
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1286 internal dispatch point for messages that are sent to
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1287 windows created by this thread. */
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1288 drain_message_queue ();
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1289 }
ff85091a55e7 (sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents: 24671
diff changeset
1290 else if (active >= nh)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1291 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1292 cp = cps[active - nh];
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1293
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1294 /* We cannot always signal SIGCHLD immediately; if we have not
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1295 finished reading the process output, we must delay sending
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1296 SIGCHLD until we do. */
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1297
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1298 if (cp->fd >= 0 && (fd_info[cp->fd].flags & FILE_AT_EOF) == 0)
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1299 fd_info[cp->fd].flags |= FILE_SEND_SIGCHLD;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1300 /* SIG_DFL for SIGCHLD is ignore */
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1301 else if (sig_handlers[SIGCHLD] != SIG_DFL &&
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1302 sig_handlers[SIGCHLD] != SIG_IGN)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1303 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1304 #ifdef FULL_DEBUG
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1305 DebPrint (("select calling SIGCHLD handler for pid %d\n",
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1306 cp->pid));
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1307 #endif
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1308 dead_child = cp;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1309 sig_handlers[SIGCHLD] (SIGCHLD);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1310 dead_child = NULL;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1311 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1312 }
22079
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1313 else if (fdindex[active] == -1)
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1314 {
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1315 /* Quit (C-g) was detected. */
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1316 errno = EINTR;
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1317 return -1;
b7a2370ee82d (sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents: 21742
diff changeset
1318 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1319 else if (fdindex[active] == 0)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1320 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1321 /* Keyboard input available */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1322 FD_SET (0, rfds);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 nr++;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1324 }
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325 else
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1326 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1327 /* must be a socket or pipe - read ahead should have
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1328 completed, either succeeding or failing. */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1329 FD_SET (fdindex[active], rfds);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1330 nr++;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1331 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1332
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1333 /* Even though wait_reading_process_output only reads from at most
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1334 one channel, we must process all channels here so that we reap
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1335 all children that have died. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1336 while (++active < nh + nc)
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1337 if (WaitForSingleObject (wait_hnd[active], 0) == WAIT_OBJECT_0)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1338 break;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1339 } while (active < nh + nc);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1340
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1341 /* If no input has arrived and timeout hasn't expired, wait again. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1342 if (nr == 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1343 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1344 DWORD elapsed = GetTickCount () - start_time;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1345
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1346 if (timeout_ms > elapsed) /* INFINITE is MAX_UINT */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1347 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1348 if (timeout_ms != INFINITE)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1349 timeout_ms -= elapsed;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1350 goto count_children;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1351 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1352 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1353
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 return nr;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1357 /* Substitute for certain kill () operations */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1358
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1359 static BOOL CALLBACK
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
1360 find_child_console (HWND hwnd, LPARAM arg)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1361 {
31115
42753ce203f8 (IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents: 26526
diff changeset
1362 child_process * cp = (child_process *) arg;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1363 DWORD thread_id;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1364 DWORD process_id;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1365
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1366 thread_id = GetWindowThreadProcessId (hwnd, &process_id);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1367 if (process_id == cp->procinfo.dwProcessId)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1368 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1369 char window_class[32];
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1370
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1371 GetClassName (hwnd, window_class, sizeof (window_class));
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1372 if (strcmp (window_class,
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1373 (os_subtype == OS_WIN95)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1374 ? "tty"
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1375 : "ConsoleWindowClass") == 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1376 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1377 cp->hwnd = hwnd;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1378 return FALSE;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1379 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1380 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1381 /* keep looking */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1382 return TRUE;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1383 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1384
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1385 int
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1386 sys_kill (int pid, int sig)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 child_process *cp;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1389 HANDLE proc_hand;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1390 int need_to_free = 0;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1391 int rc = 0;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1392
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 /* Only handle signals that will result in the process dying */
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 {
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 errno = EINVAL;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 return -1;
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1399
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 cp = find_child_pid (pid);
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1401 if (cp == NULL)
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1403 proc_hand = OpenProcess (PROCESS_TERMINATE, 0, pid);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1404 if (proc_hand == NULL)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1405 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1406 errno = EPERM;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1407 return -1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1408 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1409 need_to_free = 1;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1410 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1411 else
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1412 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1413 proc_hand = cp->procinfo.hProcess;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1414 pid = cp->procinfo.dwProcessId;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1415
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1416 /* Try to locate console window for process. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1417 EnumWindows (find_child_console, (LPARAM) cp);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1419
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
1420 if (sig == SIGINT || sig == SIGQUIT)
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1422 if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1423 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1424 BYTE control_scan_code = (BYTE) MapVirtualKey (VK_CONTROL, 0);
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
1425 /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
1426 BYTE vk_break_code = (sig == SIGINT) ? 'C' : VK_CANCEL;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1427 BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1428 HWND foreground_window;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1429
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1430 if (break_scan_code == 0)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1431 {
38022
71e8b6ae114f (create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents: 37703
diff changeset
1432 /* Fake Ctrl-C for SIGQUIT if we can't manage Ctrl-Break. */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1433 vk_break_code = 'C';
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1434 break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1435 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1436
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1437 foreground_window = GetForegroundWindow ();
24671
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1438 if (foreground_window)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1439 {
24671
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1440 /* NT 5.0, and apparently also Windows 98, will not allow
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1441 a Window to be set to foreground directly without the
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1442 user's involvement. The workaround is to attach
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1443 ourselves to the thread that owns the foreground
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1444 window, since that is the only thread that can set the
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1445 foreground window. */
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1446 DWORD foreground_thread, child_thread;
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1447 foreground_thread =
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1448 GetWindowThreadProcessId (foreground_window, NULL);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1449 if (foreground_thread == GetCurrentThreadId ()
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1450 || !AttachThreadInput (GetCurrentThreadId (),
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1451 foreground_thread, TRUE))
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1452 foreground_thread = 0;
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1453
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1454 child_thread = GetWindowThreadProcessId (cp->hwnd, NULL);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1455 if (child_thread == GetCurrentThreadId ()
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1456 || !AttachThreadInput (GetCurrentThreadId (),
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1457 child_thread, TRUE))
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1458 child_thread = 0;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1459
24671
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1460 /* Set the foreground window to the child. */
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1461 if (SetForegroundWindow (cp->hwnd))
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1462 {
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1463 /* Generate keystrokes as if user had typed Ctrl-Break or
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1464 Ctrl-C. */
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1465 keybd_event (VK_CONTROL, control_scan_code, 0, 0);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1466 keybd_event (vk_break_code, break_scan_code,
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1467 (vk_break_code == 'C' ? 0 : KEYEVENTF_EXTENDEDKEY), 0);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1468 keybd_event (vk_break_code, break_scan_code,
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1469 (vk_break_code == 'C' ? 0 : KEYEVENTF_EXTENDEDKEY)
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1470 | KEYEVENTF_KEYUP, 0);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1471 keybd_event (VK_CONTROL, control_scan_code,
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1472 KEYEVENTF_KEYUP, 0);
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1473
24671
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1474 /* Sleep for a bit to give time for Emacs frame to respond
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1475 to focus change events (if Emacs was active app). */
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1476 Sleep (100);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1477
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1478 SetForegroundWindow (foreground_window);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1479 }
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1480 /* Detach from the foreground and child threads now that
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1481 the foreground switching is over. */
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1482 if (foreground_thread)
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1483 AttachThreadInput (GetCurrentThreadId (),
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1484 foreground_thread, FALSE);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1485 if (child_thread)
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1486 AttachThreadInput (GetCurrentThreadId (),
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1487 child_thread, FALSE);
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1488 }
65ebab3569e0 (sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents: 24105
diff changeset
1489 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1490 /* Ctrl-Break is NT equivalent of SIGINT. */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1491 else if (!GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, pid))
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1493 DebPrint (("sys_kill.GenerateConsoleCtrlEvent return %d "
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 "for pid %lu\n", GetLastError (), pid));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 errno = EINVAL;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1496 rc = -1;
21742
b1c3fe58dbbe (sys_kill): Fix indenting.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21613
diff changeset
1497 }
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 else
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 {
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1501 if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1502 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1503 #if 1
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1504 if (os_subtype == OS_WIN95)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1505 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1506 /*
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1507 Another possibility is to try terminating the VDM out-right by
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1508 calling the Shell VxD (id 0x17) V86 interface, function #4
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1509 "SHELL_Destroy_VM", ie.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1510
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1511 mov edx,4
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1512 mov ebx,vm_handle
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1513 call shellapi
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1514
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1515 First need to determine the current VM handle, and then arrange for
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1516 the shellapi call to be made from the system vm (by using
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1517 Switch_VM_and_callback).
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1518
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1519 Could try to invoke DestroyVM through CallVxD.
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1520
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1521 */
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1522 #if 0
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1523 /* On Win95, posting WM_QUIT causes the 16-bit subsystem
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1524 to hang when cmdproxy is used in conjunction with
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1525 command.com for an interactive shell. Posting
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1526 WM_CLOSE pops up a dialog that, when Yes is selected,
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1527 does the same thing. TerminateProcess is also less
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1528 than ideal in that subprocesses tend to stick around
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1529 until the machine is shutdown, but at least it
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1530 doesn't freeze the 16-bit subsystem. */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1531 PostMessage (cp->hwnd, WM_QUIT, 0xff, 0);
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1532 #endif
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1533 if (!TerminateProcess (proc_hand, 0xff))
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1534 {
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1535 DebPrint (("sys_kill.TerminateProcess returned %d "
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1536 "for pid %lu\n", GetLastError (), pid));
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1537 errno = EINVAL;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1538 rc = -1;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1539 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1540 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1541 else
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1542 #endif
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1543 PostMessage (cp->hwnd, WM_CLOSE, 0, 0);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1544 }
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
1545 /* Kill the process. On W32 this doesn't kill child processes
15351
6deee3a18ba8 (sys_kill): Don't try to terminate a DOS process.
Richard M. Stallman <rms@gnu.org>
parents: 15325
diff changeset
1546 so it doesn't work very well for shells which is why it's not
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1547 used in every case. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1548 else if (!TerminateProcess (proc_hand, 0xff))
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1550 DebPrint (("sys_kill.TerminateProcess returned %d "
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 "for pid %lu\n", GetLastError (), pid));
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 errno = EINVAL;
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1553 rc = -1;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1556
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1557 if (need_to_free)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1558 CloseHandle (proc_hand);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1559
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1560 return rc;
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 }
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562
21452
bd9b548fd162 Delete incorrect prototype of report_file_error.
Karl Heuer <kwzh@gnu.org>
parents: 19712
diff changeset
1563 /* extern int report_file_error (char *, Lisp_Object); */
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1564
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1565 /* The following two routines are used to manipulate stdin, stdout, and
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1566 stderr of our child processes.
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1567
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1568 Assuming that in, out, and err are *not* inheritable, we make them
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1569 stdin, stdout, and stderr of the child as follows:
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1570
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1571 - Save the parent's current standard handles.
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1572 - Set the std handles to inheritable duplicates of the ones being passed in.
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1573 (Note that _get_osfhandle() is an io.h procedure that retrieves the
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1574 NT file handle for a crt file descriptor.)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1575 - Spawn the child, which inherits in, out, and err as stdin,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1576 stdout, and stderr. (see Spawnve)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1577 - Close the std handles passed to the child.
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1578 - Reset the parent's standard handles to the saved handles.
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1579 (see reset_standard_handles)
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1580 We assume that the caller closes in, out, and err after calling us. */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1581
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1582 void
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1583 prepare_standard_handles (int in, int out, int err, HANDLE handles[3])
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 {
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1585 HANDLE parent;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1586 HANDLE newstdin, newstdout, newstderr;
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1587
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1588 parent = GetCurrentProcess ();
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1589
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1590 handles[0] = GetStdHandle (STD_INPUT_HANDLE);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1591 handles[1] = GetStdHandle (STD_OUTPUT_HANDLE);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1592 handles[2] = GetStdHandle (STD_ERROR_HANDLE);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1593
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1594 /* make inheritable copies of the new handles */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1595 if (!DuplicateHandle (parent,
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1596 (HANDLE) _get_osfhandle (in),
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1597 parent,
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1598 &newstdin,
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1599 0,
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1600 TRUE,
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1601 DUPLICATE_SAME_ACCESS))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1602 report_file_error ("Duplicating input handle for child", Qnil);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1603
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1604 if (!DuplicateHandle (parent,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1605 (HANDLE) _get_osfhandle (out),
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1606 parent,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1607 &newstdout,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1608 0,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1609 TRUE,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1610 DUPLICATE_SAME_ACCESS))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1611 report_file_error ("Duplicating output handle for child", Qnil);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1612
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1613 if (!DuplicateHandle (parent,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1614 (HANDLE) _get_osfhandle (err),
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1615 parent,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1616 &newstderr,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1617 0,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1618 TRUE,
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1619 DUPLICATE_SAME_ACCESS))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1620 report_file_error ("Duplicating error handle for child", Qnil);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1621
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1622 /* and store them as our std handles */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1623 if (!SetStdHandle (STD_INPUT_HANDLE, newstdin))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1624 report_file_error ("Changing stdin handle", Qnil);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
1625
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1626 if (!SetStdHandle (STD_OUTPUT_HANDLE, newstdout))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1627 report_file_error ("Changing stdout handle", Qnil);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1628
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1629 if (!SetStdHandle (STD_ERROR_HANDLE, newstderr))
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1630 report_file_error ("Changing stderr handle", Qnil);
9907
2e5a14f7c44e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 }
15145
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1632
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1633 void
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1634 reset_standard_handles (int in, int out, int err, HANDLE handles[3])
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1635 {
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1636 /* close the duplicated handles passed to the child */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1637 CloseHandle (GetStdHandle (STD_INPUT_HANDLE));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1638 CloseHandle (GetStdHandle (STD_OUTPUT_HANDLE));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1639 CloseHandle (GetStdHandle (STD_ERROR_HANDLE));
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1640
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1641 /* now restore parent's saved std handles */
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1642 SetStdHandle (STD_INPUT_HANDLE, handles[0]);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1643 SetStdHandle (STD_OUTPUT_HANDLE, handles[1]);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1644 SetStdHandle (STD_ERROR_HANDLE, handles[2]);
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1645 }
86a1f426871e Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1646
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1647 void
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1648 set_process_dir (char * dir)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1649 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1650 process_dir = dir;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1651 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1652
15356
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1653 /* To avoid problems with winsock implementations that work over dial-up
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1654 connections causing or requiring a connection to exist while Emacs is
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1655 running, Emacs no longer automatically loads winsock on startup if it
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1656 is present. Instead, it will be loaded when open-network-stream is
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1657 first called.
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1658
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1659 To allow full control over when winsock is loaded, we provide these
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1660 two functions to dynamically load and unload winsock. This allows
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1661 dial-up users to only be connected when they actually need to use
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1662 socket services. */
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1663
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1664 /* From nt.c */
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1665 extern HANDLE winsock_lib;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1666 extern BOOL term_winsock (void);
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1667 extern BOOL init_winsock (int load_now);
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1668
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
1669 DEFUN ("w32-has-winsock", Fw32_has_winsock, Sw32_has_winsock, 0, 1, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1670 doc: /* Test for presence of the Windows socket library `winsock'.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1671 Returns non-nil if winsock support is present, nil otherwise.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1672
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1673 If the optional argument LOAD-NOW is non-nil, the winsock library is
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1674 also loaded immediately if not already loaded. If winsock is loaded,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1675 the winsock local hostname is returned (since this may be different from
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1676 the value of `system-name' and should supplant it), otherwise t is
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1677 returned to indicate winsock support is present. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1678 (Lisp_Object load_now)
15356
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1679 {
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1680 int have_winsock;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1681
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1682 have_winsock = init_winsock (!NILP (load_now));
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1683 if (have_winsock)
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1684 {
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1685 if (winsock_lib != NULL)
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1686 {
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1687 /* Return new value for system-name. The best way to do this
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1688 is to call init_system_name, saving and restoring the
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1689 original value to avoid side-effects. */
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1690 Lisp_Object orig_hostname = Vsystem_name;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1691 Lisp_Object hostname;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1692
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1693 init_system_name ();
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1694 hostname = Vsystem_name;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1695 Vsystem_name = orig_hostname;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1696 return hostname;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1697 }
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1698 return Qt;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1699 }
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1700 return Qnil;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1701 }
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1702
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
1703 DEFUN ("w32-unload-winsock", Fw32_unload_winsock, Sw32_unload_winsock,
15356
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1704 0, 0, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1705 doc: /* Unload the Windows socket library `winsock' if loaded.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1706 This is provided to allow dial-up socket connections to be disconnected
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1707 when no longer needed. Returns nil without unloading winsock if any
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1708 socket connections still exist. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1709 (void)
15356
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1710 {
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1711 return term_winsock () ? Qt : Qnil;
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1712 }
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
1713
15201
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
1714
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1715 /* Some miscellaneous functions that are Windows specific, but not GUI
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1716 specific (ie. are applicable in terminal or batch mode as well). */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1717
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1718 DEFUN ("w32-short-file-name", Fw32_short_file_name, Sw32_short_file_name, 1, 1, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1719 doc: /* Return the short file name version (8.3) of the full path of FILENAME.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1720 If FILENAME does not exist, return nil.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1721 All path elements in FILENAME are converted to their short names. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1722 (Lisp_Object filename)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1723 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1724 char shortname[MAX_PATH];
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1725
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
1726 CHECK_STRING (filename);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1727
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1728 /* first expand it. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1729 filename = Fexpand_file_name (filename, Qnil);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1730
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1731 /* luckily, this returns the short version of each element in the path. */
100045
3ec2cc2d35c1 * w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents: 96893
diff changeset
1732 if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname, MAX_PATH) == 0)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1733 return Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1734
108888
c2ac5cece5ea Turn `directory-sep-char' into a noop.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1735 dostounix_filename (shortname);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1736
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1737 return build_string (shortname);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1738 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1739
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1740
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1741 DEFUN ("w32-long-file-name", Fw32_long_file_name, Sw32_long_file_name,
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1742 1, 1, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1743 doc: /* Return the long file name version of the full path of FILENAME.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1744 If FILENAME does not exist, return nil.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1745 All path elements in FILENAME are converted to their long names. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1746 (Lisp_Object filename)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1747 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1748 char longname[ MAX_PATH ];
96893
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1749 int drive_only = 0;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1750
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
1751 CHECK_STRING (filename);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1752
96893
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1753 if (SBYTES (filename) == 2
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1754 && *(SDATA (filename) + 1) == ':')
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1755 drive_only = 1;
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1756
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1757 /* first expand it. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1758 filename = Fexpand_file_name (filename, Qnil);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1759
100045
3ec2cc2d35c1 * w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents: 96893
diff changeset
1760 if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname, MAX_PATH))
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1761 return Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1762
108888
c2ac5cece5ea Turn `directory-sep-char' into a noop.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1763 dostounix_filename (longname);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1764
96893
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1765 /* If we were passed only a drive, make sure that a slash is not appended
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1766 for consistency with directories. Allow for drive mapping via SUBST
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1767 in case expand-file-name is ever changed to expand those. */
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1768 if (drive_only && longname[1] == ':' && longname[2] == '/' && !longname[3])
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1769 longname[2] = '\0';
532dd6819465 (Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents: 96376
diff changeset
1770
100045
3ec2cc2d35c1 * w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents: 96893
diff changeset
1771 return DECODE_FILE (build_string (longname));
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1772 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1773
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1774 DEFUN ("w32-set-process-priority", Fw32_set_process_priority,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1775 Sw32_set_process_priority, 2, 2, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1776 doc: /* Set the priority of PROCESS to PRIORITY.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1777 If PROCESS is nil, the priority of Emacs is changed, otherwise the
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1778 priority of the process whose pid is PROCESS is changed.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1779 PRIORITY should be one of the symbols high, normal, or low;
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1780 any other symbol will be interpreted as normal.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1781
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1782 If successful, the return value is t, otherwise nil. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1783 (Lisp_Object process, Lisp_Object priority)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1784 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1785 HANDLE proc_handle = GetCurrentProcess ();
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1786 DWORD priority_class = NORMAL_PRIORITY_CLASS;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1787 Lisp_Object result = Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1788
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
1789 CHECK_SYMBOL (priority);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1790
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1791 if (!NILP (process))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1792 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1793 DWORD pid;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1794 child_process *cp;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1795
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
1796 CHECK_NUMBER (process);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1797
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1798 /* Allow pid to be an internally generated one, or one obtained
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1799 externally. This is necessary because real pids on Win95 are
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1800 negative. */
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1801
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1802 pid = XINT (process);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1803 cp = find_child_pid (pid);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1804 if (cp != NULL)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1805 pid = cp->procinfo.dwProcessId;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1806
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1807 proc_handle = OpenProcess (PROCESS_SET_INFORMATION, FALSE, pid);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1808 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1809
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1810 if (EQ (priority, Qhigh))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1811 priority_class = HIGH_PRIORITY_CLASS;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1812 else if (EQ (priority, Qlow))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1813 priority_class = IDLE_PRIORITY_CLASS;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1814
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1815 if (proc_handle != NULL)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1816 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1817 if (SetPriorityClass (proc_handle, priority_class))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1818 result = Qt;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1819 if (!NILP (process))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1820 CloseHandle (proc_handle);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1821 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1822
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1823 return result;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1824 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1825
73091
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1826 #ifdef HAVE_LANGINFO_CODESET
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1827 /* Emulation of nl_langinfo. Used in fns.c:Flocale_info. */
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1828 char *
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1829 nl_langinfo (nl_item item)
73091
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1830 {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1831 /* Conversion of Posix item numbers to their Windows equivalents. */
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1832 static const LCTYPE w32item[] = {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1833 LOCALE_IDEFAULTANSICODEPAGE,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1834 LOCALE_SDAYNAME1, LOCALE_SDAYNAME2, LOCALE_SDAYNAME3,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1835 LOCALE_SDAYNAME4, LOCALE_SDAYNAME5, LOCALE_SDAYNAME6, LOCALE_SDAYNAME7,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1836 LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1837 LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1838 LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1839 LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1840 };
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1841
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1842 static char *nl_langinfo_buf = NULL;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1843 static int nl_langinfo_len = 0;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1844
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1845 if (nl_langinfo_len <= 0)
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1846 nl_langinfo_buf = xmalloc (nl_langinfo_len = 1);
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1847
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1848 if (item < 0 || item >= _NL_NUM)
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1849 nl_langinfo_buf[0] = 0;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1850 else
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1851 {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1852 LCID cloc = GetThreadLocale ();
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1853 int need_len = GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1854 NULL, 0);
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1855
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1856 if (need_len <= 0)
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1857 nl_langinfo_buf[0] = 0;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1858 else
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1859 {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1860 if (item == CODESET)
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1861 {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1862 need_len += 2; /* for the "cp" prefix */
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1863 if (need_len < 8) /* for the case we call GetACP */
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1864 need_len = 8;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1865 }
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1866 if (nl_langinfo_len <= need_len)
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1867 nl_langinfo_buf = xrealloc (nl_langinfo_buf,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1868 nl_langinfo_len = need_len);
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1869 if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1870 nl_langinfo_buf, nl_langinfo_len))
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1871 nl_langinfo_buf[0] = 0;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1872 else if (item == CODESET)
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1873 {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1874 if (strcmp (nl_langinfo_buf, "0") == 0 /* CP_ACP */
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1875 || strcmp (nl_langinfo_buf, "1") == 0) /* CP_OEMCP */
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1876 sprintf (nl_langinfo_buf, "cp%u", GetACP ());
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1877 else
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1878 {
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1879 memmove (nl_langinfo_buf + 2, nl_langinfo_buf,
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1880 strlen (nl_langinfo_buf) + 1);
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1881 nl_langinfo_buf[0] = 'c';
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1882 nl_langinfo_buf[1] = 'p';
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1883 }
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1884 }
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1885 }
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1886 }
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1887 return nl_langinfo_buf;
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1888 }
fd4e9d08fa35 (nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 71901
diff changeset
1889 #endif /* HAVE_LANGINFO_CODESET */
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1890
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1891 DEFUN ("w32-get-locale-info", Fw32_get_locale_info,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1892 Sw32_get_locale_info, 1, 2, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1893 doc: /* Return information about the Windows locale LCID.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1894 By default, return a three letter locale code which encodes the default
100062
d4660dbaa550 * w32proc.c (Fw32_get_locale_info): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 100045
diff changeset
1895 language as the first two characters, and the country or regional variant
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1896 as the third letter. For example, ENU refers to `English (United States)',
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1897 while ENC means `English (Canadian)'.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1898
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1899 If the optional argument LONGFORM is t, the long form of the locale
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1900 name is returned, e.g. `English (United States)' instead; if LONGFORM
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1901 is a number, it is interpreted as an LCTYPE constant and the corresponding
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1902 locale information is returned.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1903
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1904 If LCID (a 16-bit number) is not a valid locale, the result is nil. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1905 (Lisp_Object lcid, Lisp_Object longform)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1906 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1907 int got_abbrev;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1908 int got_full;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1909 char abbrev_name[32] = { 0 };
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1910 char full_name[256] = { 0 };
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1911
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
1912 CHECK_NUMBER (lcid);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1913
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1914 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1915 return Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1916
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1917 if (NILP (longform))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1918 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1919 got_abbrev = GetLocaleInfo (XINT (lcid),
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1920 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1921 abbrev_name, sizeof (abbrev_name));
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1922 if (got_abbrev)
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1923 return build_string (abbrev_name);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1924 }
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1925 else if (EQ (longform, Qt))
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1926 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1927 got_full = GetLocaleInfo (XINT (lcid),
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1928 LOCALE_SLANGUAGE | LOCALE_USE_CP_ACP,
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1929 full_name, sizeof (full_name));
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1930 if (got_full)
100351
d23b1588c7c1 Move decoding of locale info from Lisp to C.
Juanma Barranquero <lekktu@gmail.com>
parents: 100062
diff changeset
1931 return DECODE_SYSTEM (build_string (full_name));
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1932 }
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1933 else if (NUMBERP (longform))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1934 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1935 got_full = GetLocaleInfo (XINT (lcid),
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1936 XINT (longform),
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1937 full_name, sizeof (full_name));
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1938 if (got_full)
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1939 return make_unibyte_string (full_name, got_full);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
1940 }
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1941
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1942 return Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1943 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1944
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1945
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1946 DEFUN ("w32-get-current-locale-id", Fw32_get_current_locale_id,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1947 Sw32_get_current_locale_id, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1948 doc: /* Return Windows locale id for current locale setting.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1949 This is a numerical value; use `w32-get-locale-info' to convert to a
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1950 human-readable form. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1951 (void)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1952 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1953 return make_number (GetThreadLocale ());
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1954 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
1955
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
1956 static DWORD
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1957 int_from_hex (char * s)
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1958 {
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1959 DWORD val = 0;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1960 static char hex[] = "0123456789abcdefABCDEF";
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1961 char * p;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1962
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1963 while (*s && (p = strchr (hex, *s)) != NULL)
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1964 {
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1965 unsigned digit = p - hex;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1966 if (digit > 15)
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1967 digit -= 6;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1968 val = val * 16 + digit;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1969 s++;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1970 }
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1971 return val;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1972 }
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1973
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1974 /* We need to build a global list, since the EnumSystemLocale callback
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1975 function isn't given a context pointer. */
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1976 Lisp_Object Vw32_valid_locale_ids;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1977
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
1978 static BOOL CALLBACK
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1979 enum_locale_fn (LPTSTR localeNum)
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1980 {
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1981 DWORD id = int_from_hex (localeNum);
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1982 Vw32_valid_locale_ids = Fcons (make_number (id), Vw32_valid_locale_ids);
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1983 return TRUE;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1984 }
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1985
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1986 DEFUN ("w32-get-valid-locale-ids", Fw32_get_valid_locale_ids,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1987 Sw32_get_valid_locale_ids, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1988 doc: /* Return list of all valid Windows locale ids.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1989 Each id is a numerical value; use `w32-get-locale-info' to convert to a
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
1990 human-readable form. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
1991 (void)
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1992 {
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1993 Vw32_valid_locale_ids = Qnil;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1994
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1995 EnumSystemLocales (enum_locale_fn, LCID_SUPPORTED);
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1996
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1997 Vw32_valid_locale_ids = Fnreverse (Vw32_valid_locale_ids);
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1998 return Vw32_valid_locale_ids;
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
1999 }
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2000
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2001
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2002 DEFUN ("w32-get-default-locale-id", Fw32_get_default_locale_id, Sw32_get_default_locale_id, 0, 1, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2003 doc: /* Return Windows locale id for default locale setting.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2004 By default, the system default locale setting is returned; if the optional
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2005 parameter USERP is non-nil, the user default locale setting is returned.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2006 This is a numerical value; use `w32-get-locale-info' to convert to a
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2007 human-readable form. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2008 (Lisp_Object userp)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2009 {
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2010 if (NILP (userp))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2011 return make_number (GetSystemDefaultLCID ());
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2012 return make_number (GetUserDefaultLCID ());
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2013 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2014
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
2015
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2016 DEFUN ("w32-set-current-locale", Fw32_set_current_locale, Sw32_set_current_locale, 1, 1, 0,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2017 doc: /* Make Windows locale LCID be the current locale setting for Emacs.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2018 If successful, the new locale id is returned, otherwise nil. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2019 (Lisp_Object lcid)
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2020 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
2021 CHECK_NUMBER (lcid);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2022
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2023 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2024 return Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2025
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2026 if (!SetThreadLocale (XINT (lcid)))
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2027 return Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2028
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2029 /* Need to set input thread locale if present. */
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2030 if (dwWindowsThreadId)
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2031 /* Reply is not needed. */
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2032 PostThreadMessage (dwWindowsThreadId, WM_EMACS_SETLOCALE, XINT (lcid), 0);
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2033
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2034 return make_number (GetThreadLocale ());
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2035 }
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2036
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2037
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2038 /* We need to build a global list, since the EnumCodePages callback
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2039 function isn't given a context pointer. */
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2040 Lisp_Object Vw32_valid_codepages;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2041
110975
e0ac9a58795e src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents: 110431
diff changeset
2042 static BOOL CALLBACK
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
2043 enum_codepage_fn (LPTSTR codepageNum)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2044 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2045 DWORD id = atoi (codepageNum);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2046 Vw32_valid_codepages = Fcons (make_number (id), Vw32_valid_codepages);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2047 return TRUE;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2048 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2049
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2050 DEFUN ("w32-get-valid-codepages", Fw32_get_valid_codepages,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2051 Sw32_get_valid_codepages, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2052 doc: /* Return list of all valid Windows codepages. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2053 (void)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2054 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2055 Vw32_valid_codepages = Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2056
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2057 EnumSystemCodePages (enum_codepage_fn, CP_SUPPORTED);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2058
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2059 Vw32_valid_codepages = Fnreverse (Vw32_valid_codepages);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2060 return Vw32_valid_codepages;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2061 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2062
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2063
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2064 DEFUN ("w32-get-console-codepage", Fw32_get_console_codepage,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2065 Sw32_get_console_codepage, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2066 doc: /* Return current Windows codepage for console input. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2067 (void)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2068 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2069 return make_number (GetConsoleCP ());
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2070 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2071
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
2072
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2073 DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2074 Sw32_set_console_codepage, 1, 1, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2075 doc: /* Make Windows codepage CP be the current codepage setting for Emacs.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2076 The codepage setting affects keyboard input and display in tty mode.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2077 If successful, the new CP is returned, otherwise nil. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2078 (Lisp_Object cp)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2079 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
2080 CHECK_NUMBER (cp);
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2081
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2082 if (!IsValidCodePage (XINT (cp)))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2083 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2084
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2085 if (!SetConsoleCP (XINT (cp)))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2086 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2087
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2088 return make_number (GetConsoleCP ());
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2089 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2090
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2091
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2092 DEFUN ("w32-get-console-output-codepage", Fw32_get_console_output_codepage,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2093 Sw32_get_console_output_codepage, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2094 doc: /* Return current Windows codepage for console output. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2095 (void)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2096 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2097 return make_number (GetConsoleOutputCP ());
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2098 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2099
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
2100
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2101 DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2102 Sw32_set_console_output_codepage, 1, 1, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2103 doc: /* Make Windows codepage CP be the current codepage setting for Emacs.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2104 The codepage setting affects keyboard input and display in tty mode.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2105 If successful, the new CP is returned, otherwise nil. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2106 (Lisp_Object cp)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2107 {
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
2108 CHECK_NUMBER (cp);
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2109
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2110 if (!IsValidCodePage (XINT (cp)))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2111 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2112
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2113 if (!SetConsoleOutputCP (XINT (cp)))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2114 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2115
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2116 return make_number (GetConsoleOutputCP ());
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2117 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2118
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2119
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2120 DEFUN ("w32-get-codepage-charset", Fw32_get_codepage_charset,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2121 Sw32_get_codepage_charset, 1, 1, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2122 doc: /* Return charset of codepage CP.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2123 Returns nil if the codepage is not valid. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2124 (Lisp_Object cp)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2125 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2126 CHARSETINFO info;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2127
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
2128 CHECK_NUMBER (cp);
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2129
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2130 if (!IsValidCodePage (XINT (cp)))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2131 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2132
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2133 if (TranslateCharsetInfo ((DWORD *) XINT (cp), &info, TCI_SRCCODEPAGE))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2134 return make_number (info.ciCharset);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2135
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2136 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2137 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2138
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2139
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2140 DEFUN ("w32-get-valid-keyboard-layouts", Fw32_get_valid_keyboard_layouts,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2141 Sw32_get_valid_keyboard_layouts, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2142 doc: /* Return list of Windows keyboard languages and layouts.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2143 The return value is a list of pairs of language id and layout id. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2144 (void)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2145 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2146 int num_layouts = GetKeyboardLayoutList (0, NULL);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2147 HKL * layouts = (HKL *) alloca (num_layouts * sizeof (HKL));
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2148 Lisp_Object obj = Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2149
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2150 if (GetKeyboardLayoutList (num_layouts, layouts) == num_layouts)
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2151 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2152 while (--num_layouts >= 0)
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2153 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2154 DWORD kl = (DWORD) layouts[num_layouts];
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2155
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2156 obj = Fcons (Fcons (make_number (kl & 0xffff),
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2157 make_number ((kl >> 16) & 0xffff)),
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2158 obj);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2159 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2160 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2161
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2162 return obj;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2163 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2164
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2165
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2166 DEFUN ("w32-get-keyboard-layout", Fw32_get_keyboard_layout,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2167 Sw32_get_keyboard_layout, 0, 0, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2168 doc: /* Return current Windows keyboard language and layout.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2169 The return value is the cons of the language id and the layout id. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2170 (void)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2171 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2172 DWORD kl = (DWORD) GetKeyboardLayout (dwWindowsThreadId);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2173
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2174 return Fcons (make_number (kl & 0xffff),
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2175 make_number ((kl >> 16) & 0xffff));
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2176 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2177
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
2178
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2179 DEFUN ("w32-set-keyboard-layout", Fw32_set_keyboard_layout,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2180 Sw32_set_keyboard_layout, 1, 1, 0,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2181 doc: /* Make LAYOUT be the current keyboard layout for Emacs.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2182 The keyboard layout setting affects interpretation of keyboard input.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2183 If successful, the new layout id is returned, otherwise nil. */)
109179
8cfee7d2955f Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109160
diff changeset
2184 (Lisp_Object layout)
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2185 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2186 DWORD kl;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2187
40656
cdfd4d09b79a Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents: 39812
diff changeset
2188 CHECK_CONS (layout);
40752
8b5deb3bca03 (Fw32_set_keyboard_layout): Use CHECK_NUMBER_CAR and
Andrew Innes <andrewi@gnu.org>
parents: 40656
diff changeset
2189 CHECK_NUMBER_CAR (layout);
8b5deb3bca03 (Fw32_set_keyboard_layout): Use CHECK_NUMBER_CAR and
Andrew Innes <andrewi@gnu.org>
parents: 40656
diff changeset
2190 CHECK_NUMBER_CDR (layout);
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2191
25646
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 24915
diff changeset
2192 kl = (XINT (XCAR (layout)) & 0xffff)
9154af188477 Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents: 24915
diff changeset
2193 | (XINT (XCDR (layout)) << 16);
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2194
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2195 /* Synchronize layout with input thread. */
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2196 if (dwWindowsThreadId)
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2197 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2198 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_SETKEYBOARDLAYOUT,
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2199 (WPARAM) kl, 0))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2200 {
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2201 MSG msg;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2202 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2203
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2204 if (msg.wParam == 0)
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2205 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2206 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2207 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2208 else if (!ActivateKeyboardLayout ((HKL) kl, 0))
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2209 return Qnil;
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2210
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2211 return Fw32_get_keyboard_layout ();
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2212 }
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2213
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2214
110994
734b2470f93c src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
2215 void
109152
e27859da5624 src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents: 108888
diff changeset
2216 syms_of_ntproc (void)
15201
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
2217 {
90921
47c076d206e6 (syms_of_ntproc): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90737
diff changeset
2218 DEFSYM (Qhigh, "high");
47c076d206e6 (syms_of_ntproc): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents: 90737
diff changeset
2219 DEFSYM (Qlow, "low");
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2220
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
2221 defsubr (&Sw32_has_winsock);
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
2222 defsubr (&Sw32_unload_winsock);
110431
9fe8167bbd9b Don't make W32 code conditional on HAVE_SOCKETS, it's always defined.
Juanma Barranquero <lekktu@gmail.com>
parents: 109179
diff changeset
2223
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2224 defsubr (&Sw32_short_file_name);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2225 defsubr (&Sw32_long_file_name);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2226 defsubr (&Sw32_set_process_priority);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2227 defsubr (&Sw32_get_locale_info);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2228 defsubr (&Sw32_get_current_locale_id);
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2229 defsubr (&Sw32_get_default_locale_id);
21613
fe4f5bfae371 (w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents: 21452
diff changeset
2230 defsubr (&Sw32_get_valid_locale_ids);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2231 defsubr (&Sw32_set_current_locale);
15356
1a917c5d944c (Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents: 15351
diff changeset
2232
23678
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2233 defsubr (&Sw32_get_console_codepage);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2234 defsubr (&Sw32_set_console_codepage);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2235 defsubr (&Sw32_get_console_output_codepage);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2236 defsubr (&Sw32_set_console_output_codepage);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2237 defsubr (&Sw32_get_valid_codepages);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2238 defsubr (&Sw32_get_codepage_charset);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2239
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2240 defsubr (&Sw32_get_valid_keyboard_layouts);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2241 defsubr (&Sw32_get_keyboard_layout);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2242 defsubr (&Sw32_set_keyboard_layout);
b2480e274f42 (sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents: 22298
diff changeset
2243
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2244 DEFVAR_LISP ("w32-quote-process-args", Vw32_quote_process_args,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2245 doc: /* Non-nil enables quoting of process arguments to ensure correct parsing.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2246 Because Windows does not directly pass argv arrays to child processes,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2247 programs have to reconstruct the argv array by parsing the command
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2248 line string. For an argument to contain a space, it must be enclosed
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2249 in double quotes or it will be parsed as multiple arguments.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2250
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2251 If the value is a character, that character will be used to escape any
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2252 quote characters that appear, otherwise a suitable escape character
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2253 will be chosen based on the type of the program. */);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2254 Vw32_quote_process_args = Qt;
15247
874a66251747 (Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents: 15201
diff changeset
2255
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
2256 DEFVAR_LISP ("w32-start-process-show-window",
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2257 Vw32_start_process_show_window,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2258 doc: /* When nil, new child processes hide their windows.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2259 When non-nil, they show their window in the method of their choice.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2260 This variable doesn't affect GUI applications, which will never be hidden. */);
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
2261 Vw32_start_process_show_window = Qnil;
16000
b5ecd5022991 (Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15419
diff changeset
2262
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2263 DEFVAR_LISP ("w32-start-process-share-console",
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2264 Vw32_start_process_share_console,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2265 doc: /* When nil, new child processes are given a new console.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2266 When non-nil, they share the Emacs console; this has the limitation of
43548
c185eb97b9ee (syms_of_ntproc): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
2267 allowing only one DOS subprocess to run at a time (whether started directly
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2268 or indirectly by Emacs), and preventing Emacs from cleanly terminating the
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2269 subprocess group, but may allow Emacs to interrupt a subprocess that doesn't
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2270 otherwise respond to interrupts from Emacs. */);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2271 Vw32_start_process_share_console = Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2272
23949
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
2273 DEFVAR_LISP ("w32-start-process-inherit-error-mode",
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2274 Vw32_start_process_inherit_error_mode,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2275 doc: /* When nil, new child processes revert to the default error mode.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2276 When non-nil, they inherit their error mode setting from Emacs, which stops
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2277 them blocking when trying to access unmounted drives etc. */);
23949
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
2278 Vw32_start_process_inherit_error_mode = Qt;
9f8417cca07b (Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 23678
diff changeset
2279
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2280 DEFVAR_INT ("w32-pipe-read-delay", w32_pipe_read_delay,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2281 doc: /* Forced delay before reading subprocess output.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2282 This is done to improve the buffering of subprocess output, by
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2283 avoiding the inefficiency of frequently reading small amounts of data.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2284
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2285 If positive, the value is the number of milliseconds to sleep before
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2286 reading the subprocess output. If negative, the magnitude is the number
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2287 of time slices to wait (effectively boosting the priority of the child
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2288 process temporarily). A value of zero disables waiting entirely. */);
55642
d69e0fb91340 * w32proc.c (w32_pipe_read_delay): Rename from Vw32_pipe_read_delay
Jason Rumney <jasonr@gnu.org>
parents: 52401
diff changeset
2289 w32_pipe_read_delay = 50;
15325
5c8e4ef3137c (Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15247
diff changeset
2290
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2291 DEFVAR_LISP ("w32-downcase-file-names", Vw32_downcase_file_names,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2292 doc: /* Non-nil means convert all-upper case file names to lower case.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2293 This applies when performing completions and file name expansion.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2294 Note that the value of this setting also affects remote file names,
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2295 so you probably don't want to set to non-nil if you use case-sensitive
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 46750
diff changeset
2296 filesystems via ange-ftp. */);
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16000
diff changeset
2297 Vw32_downcase_file_names = Qnil;
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2298
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2299 #if 0
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2300 DEFVAR_LISP ("w32-generate-fake-inodes", Vw32_generate_fake_inodes,
40962
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2301 doc: /* Non-nil means attempt to fake realistic inode values.
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2302 This works by hashing the truename of files, and should detect
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2303 aliasing between long and short (8.3 DOS) names, but can have
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2304 false positives because of hash collisions. Note that determing
f66d09d1bb2f Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents: 40752
diff changeset
2305 the truename of a file can be slow. */);
19712
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2306 Vw32_generate_fake_inodes = Qnil;
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2307 #endif
9a6e50f6b471 Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
2308
112364
42e22c4f06b7 Move all DEFVAR'd globals into a structure -- threading infrastructure
Tom Tromey <tromey@redhat.com>
parents: 112228
diff changeset
2309 DEFVAR_LISP ("w32-get-true-file-attributes", Vw32_get_true_file_attributes,
94839
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2310 doc: /* Non-nil means determine accurate file attributes in `file-attributes'.
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2311 This option controls whether to issue additional system calls to determine
103813
c7da7466b614 (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 100951
diff changeset
2312 accurate link counts, file type, and ownership information. It is more
94839
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2313 useful for files on NTFS volumes, where hard links and file security are
103813
c7da7466b614 (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 100951
diff changeset
2314 supported, than on volumes of the FAT family.
94839
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2315
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2316 Without these system calls, link count will always be reported as 1 and file
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2317 ownership will be attributed to the current user.
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2318 The default value `local' means only issue these system calls for files
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2319 on local fixed drives. A value of nil means never issue them.
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2320 Any other non-nil value means do this even on remote and removable drives
f82e9e80393e (syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 94293
diff changeset
2321 where the performance impact may be noticeable even on modern hardware. */);
80485
f1f27e9c15d7 (syms_of_ntproc): Change Vw32_get_true_file attributes
Jason Rumney <jasonr@gnu.org>
parents: 79759
diff changeset
2322 Vw32_get_true_file_attributes = Qlocal;
64363
71c7519df9b7 (syms_of_ntproc): staticpro Qhigh, Qlow,
Eli Zaretskii <eliz@gnu.org>
parents: 64084
diff changeset
2323
71c7519df9b7 (syms_of_ntproc): staticpro Qhigh, Qlow,
Eli Zaretskii <eliz@gnu.org>
parents: 64084
diff changeset
2324 staticpro (&Vw32_valid_locale_ids);
71c7519df9b7 (syms_of_ntproc): staticpro Qhigh, Qlow,
Eli Zaretskii <eliz@gnu.org>
parents: 64084
diff changeset
2325 staticpro (&Vw32_valid_codepages);
15201
43551ec4b69d (Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 15145
diff changeset
2326 }
111551
3207606734d5 Remove config.h include guards.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 110997
diff changeset
2327 /* end of w32proc.c */
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
2328