1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-03 10:31:37 -08:00
Commit graph

33931 commits

Author SHA1 Message Date
Eli Zaretskii
e86f51344b Avoid busy-waiting for child processes on Windows. (Bug#13086)
src/w32proc.c (waitpid): Avoid busy-waiting when called with WNOHANG
 if the child process is still running.  Instead, exit the wait
 loop and return zero.
2012-12-06 20:36:22 +02:00
Dmitry Antipov
1700db3c71 * frame.h (x_char_width, x_char_height): Remove prototypes.
* w32term.h (x_char_width, x_char_height): Likewise.
* xfns.c (x_char_width, x_char_height): Remove.
* w32fns.c (x_char_width, x_char_height): Likewise.
* nsfns.c (x_char_width, x_char_height): Likewise.
* frame.c (Fframe_char_width): Use FRAME_COLUMN_WIDTH for
all window frames.
(Fframe_char_height): Likewise with FRAME_LINE_HEIGHT.
* keyboard.c (command_loop_1): Remove prototype.
(command_loop_2, top_level_1): Add static to match prototype.
2012-12-06 17:48:11 +04:00
Paul Eggert
35fb805045 Fix a recently-introduced delete-process race condition.
* callproc.c, process.h (record_kill_process):
New function, containing part of the old call_process_kill.
(call_process_kill): Use it.
This does not change call_process_kill's behavior.
* process.c (Fdelete_process): Use record_kill_process to fix a
race condition that could cause Emacs to lose track of a child.
2012-12-05 23:31:58 -08:00
Dmitry Antipov
565212e598 Avoid code duplication between prev_frame and next_frame.
* frame.c (candidate_frame): New function.  Add comment.
(prev_frame, next_frame): Use it.  Adjust comment.
2012-12-06 10:23:51 +04:00
Glenn Morris
d8ad4d3ff9 Merge from emacs-24; up to 2012-11-24T16:58:43Z!cyd@gnu.org 2012-12-05 22:17:10 -08:00
Paul Eggert
644d3f0dbf Minor call-process cleanups.
* callproc.c (Fcall_process): Do record-unwind-protect on MSDOS
at the same time as other platforms, to simplify analysis.
No need for fd0_volatile since we have synch_process_fd.
Avoid needless emacs_close; arg is always negative.
2012-12-05 10:29:52 -08:00
Eli Zaretskii
7c2fcf9bad Don't pass un-encoded file name to mkstemp.
src/callproc.c (Fcall_process_region): Encode expanded temp file
 pattern before passing it to mkstemp or mktemp.
2012-12-05 19:39:39 +02:00
Eli Zaretskii
d3cefd1358 Fix one part of bug #13079 with temporary files in call-process-region.
src/callproc.c (Fcall_process_region) [!HAVE_MKSTEMP]: If mktemp
 fails, signal an error instead of continuing with an empty
 string.
2012-12-05 19:10:00 +02:00
Andreas Schwab
396376f1ae * callproc.c (Fcall_process): Fix specpdl nesting for asynchronous
processes.
2012-12-04 22:18:37 +01:00
Eli Zaretskii
2e7cddd303 Fix another instance of bug #12933 with non-ASCII file names on Windows.
src/fileio.c (file_name_as_directory, directory_file_name) [DOS_NT]:
 Encode the file name before passing it to dostounix_filename, in
 case it will downcase it (under w32-downcase-file-names).
2012-12-04 20:48:01 +02:00
Dmitry Antipov
350f51adac * lisp.h (Mouse_HLInfo): Remove set-but-unused mouse_face_image_state
member.  Adjust users.  Convert mouse_face_past_end, mouse_face_defer
and mouse_face_hidden members to a bitfields.
* frame.h (struct frame): Remove set-but-not-used space_width member.
(FRAME_SPACE_WIDTH): Remove.
* nsterm.m, w32term.c, xterm.c: Adjust users.
* termchar.h (struct tty_display_info): Remove set-but-unused se_is_so
member.  Adjust users.  Convert term_initted, delete_in_insert_mode,
costs_set, insert_mode, standout_mode, cursor_hidden and flow_control
members to a bitfields.
2012-12-04 19:15:30 +04:00
Paul Eggert
bb5f74ee84 Don't let call-process be a zombie factory.
Fixing this bug required some cleanup of the signal-handling code.
As a side effect, this change also fixes a longstanding rare race
condition whereby Emacs could mistakenly kill unrelated processes,
and it fixes a bug where a second C-g does not kill a recalcitrant
synchronous process in GNU/Linux and similar platforms.
The patch should also fix the last vestiges of Bug#9488,
a bug which has mostly been fixed on the trunk by other changes.
* callproc.c, process.h (synch_process_alive, synch_process_death)
(synch_process_termsig, sync_process_retcode):
Remove.  All uses removed, to simplify analysis and so that
less consing is done inside critical sections.
* callproc.c (call_process_exited): Remove.  All uses replaced
with !synch_process_pid.
* callproc.c (synch_process_pid, synch_process_fd): New static vars.
These take the role of what used to be in unwind-protect arg.
All uses changed.
(block_child_signal, unblock_child_signal):
New functions, to avoid races that could kill innocent-victim processes.
(call_process_kill, call_process_cleanup, Fcall_process): Use them.
(call_process_kill): Record killed processes as deleted, so that
zombies do not clutter up the system.  Do this inside a critical
section, to avoid a race that would allow the clutter.
(call_process_cleanup): Fix code so that the second C-g works again
on common platforms such as GNU/Linux.
(Fcall_process): Create the child process in a critical section,
to fix a race condition.  If creating an asynchronous process,
record it as deleted so that zombies do not clutter up the system.
Do unwind-protect for WINDOWSNT too, as that's simpler in the
light of these changes.  Omit unnecessary call to emacs_close
before failure, as the unwind-protect code does that.
* callproc.c (call_process_cleanup):
* w32proc.c (waitpid): Simplify now that synch_process_alive is gone.
* process.c (record_deleted_pid): New function, containing
code refactored out of Fdelete_process.
(Fdelete_process): Use it.
(process_status_retrieved): Remove.  All callers changed to use
child_status_change.
(record_child_status_change): Remove, folding its contents into ...
(handle_child_signal): ... this signal handler.  Now, this
function is purely a handler for SIGCHLD, and is not called after
a synchronous waitpid returns; the synchronous code is moved to
wait_for_termination.  There is no need to worry about reaping
more than one child now.
* sysdep.c (get_child_status, child_status_changed): New functions.
(wait_for_termination): Now takes int * status and bool
interruptible arguments, too.  Do not record child status change;
that's now the caller's responsibility.  All callers changed.
Reimplement in terms of get_child_status.
(wait_for_termination_1, interruptible_wait_for_termination):
Remove.  All callers changed to use wait_for_termination.
* syswait.h: Include <stdbool.h>, for bool.
(record_child_status_change, interruptible_wait_for_termination):
Remove decls.
(record_deleted_pid, child_status_changed): New decls.
(wait_for_termination): Adjust to API changes noted above.

Fixes: debbugs:12980
2012-12-03 13:42:12 -08:00
Paul Eggert
bc9dbce6ee * bytecode.c, lisp.h (Qbytecode): Remove.
No longer needed after 2012-11-20 interactive-p changes.
2012-12-03 13:07:47 -08:00
Eli Zaretskii
3cf3c60796 Fix bug #13055 with cursor positioning inside scroll-margin.
src/xdisp.c (redisplay_window): If the cursor is visible, but inside
 the scroll margin, move point outside the margin.
2012-12-03 22:48:12 +02:00
Jan Djärv
005c8d1340 * gtkutil.c (my_log_handler): New function.
(xg_set_geometry): Set log handler to my_log_handler.

Fixes: debbugs:11177
2012-12-03 20:16:17 +01:00
Dmitry Antipov
20edc1c9ed * lisp.h (modify_region): Rename to...
(modify_region_1): ...new prototype.
* textprop.c (modify_region): Now static.  Adjust users.
* insdel.c (modify_region): Rename to...
(modify_region_1): ...new function to work with current buffer.
Adjust comment and users.  Use true and false for boolean arg.
2012-12-03 18:13:06 +04:00
Dmitry Antipov
62c2e5ed3a * alloc.c (free_save_value): New function.
(safe_alloca_unwind): Use it.
* lisp.h (free_save_value): New prototype.
* editfns.c (save_excursion_save): Use Lisp_Misc_Save_Value.
Add comment.
(save_excursion_restore): Adjust to match saved data structure.
Use free_save_value to offload some work from GC.  Drop obsolete
#if 0 code.
2012-12-03 12:06:02 +04:00
Glenn Morris
c5bc2d1d05 Merge from emacs-24; up to 2012-11-23T06:23:28Z!cyd@gnu.org 2012-12-02 17:08:31 -08:00
Paul Eggert
2dd2e62273 Fix xpalloc confusion after memory is exhausted.
* alloc.c (xpalloc): Comment fix.
* charset.c (Fdefine_charset_internal): If xpalloc exhausts memory
and signals an error, do not clear charset_table_size, as
charset_table is still valid.
* doprnt.c (evxprintf): Clear *BUF after freeing it.
2012-12-02 15:11:42 -08:00
Paul Eggert
21e54a94d7 Use execve to avoid need to munge environ.
* callproc.c (Fcall_process):
* process.c (create_process):
Don't save and restore environ;	no longer needed.
* callproc.c (child_setup):
Use execve, not execvp, to preserve environ.

Fixes: debbugs:13054
2012-12-02 11:16:45 -08:00
Paul Eggert
3e5490f7a5 * xterm.c (x_draw_image_relief): Remove unused locals.
Fixes: debbugs:10500
2012-12-01 17:06:14 -06:00
YAMAMOTO Mitsuharu
75b4f59c27 Fix drawing of relief rects on X and W32.
* xterm.c (x_draw_relief_rect, x_draw_image_relief): Fix relief
display for sliced images.

* w32term.c (w32_draw_relief_rect, x_draw_image_relief): Likewise.

Fixes: debbugs:10500
2012-12-01 10:38:11 +08:00
Chong Yidong
a24580314d * fileio.c (Vauto_save_list_file_name): Minor doc fix. 2012-12-01 09:49:48 +08:00
Juanma Barranquero
f8aff4c6b8 src/doc.c: Fix bug#13034.
(Fdocumentation): Re-add handling of function-documentation,
accidentally removed in 2012-11-09T04:10:16Z!monnier@iro.umontreal.ca.
2012-11-30 18:27:41 +01:00
Fabrice Popineau
c7b36b9550 Fix compilation problems with 64-bit MSVC compiler.
src/w32fns.c: Remove prototype of atof.
 (syspage_mask): Declared DWORD_PTR, for compatibility with 64-bit
 builds.
 (file_dialog_callback): Declared UINT_PTR.
 src/w32common.h (syspage_mask): Declare DWORD_PTR, for compatibility
 with 64-bit builds.
 src/w32.c (FILE_DEVICE_FILE_SYSTEM, METHOD_BUFFERED)
 (FILE_ANY_ACCESS, CTL_CODE) [_MSC_VER]: Define only if not already
 defined.
2012-11-30 17:14:22 +02:00
Eli Zaretskii
f43ce1c197 Fix commentary to buffer_shared_and_changed. 2012-11-30 11:23:15 +02:00
Eli Zaretskii
cbf8a8c744 Fix wording of commentary to 'struct face' in dispextern.h. 2012-11-29 18:26:25 +02:00
Dmitry Antipov
3940b924e7 * xdisp.c (window_outdated): Remove eassert since it hits
some suspicious corner cases (see Bug#13007 and Bug#13012).
(mode_line_update_needed): New function.
(redisplay_internal, redisplay_window): Use it.
(ensure_selected_frame): New function.
(redisplay_internal, unwind_redisplay): Use it.
(redisplay_internal): Move comment about buffer_shared...
(buffer_shared_and_changed): ...near to its real use.
2012-11-29 10:00:21 +04:00
Paul Eggert
4a9204fe04 * callproc.c (Fcall_process): Don't misreport vfork failure. 2012-11-28 16:36:22 -08:00
Paul Eggert
60aeceb8c4 * callproc.c (Fcall_process): Fix vfork portability problems.
Do not assume that fd[0], count, filefd, and save_environ survive
vfork.  Fix bug whereby wrong errno value could be reported for
pipe failure.  Some minor cleanups, too, as follows.  Move buf and
bufsize to the context where they're needed.  Change new_argv to
be of type char **, as this is more convenient and avoids casts.
(CALLPROC_BUFFER_SIZE_MIN, CALLPROC_BUFFER_SIZE_MAX):
Now local constants, not macros.
2012-11-28 14:33:35 -08:00
Glenn Morris
a9de9f0c05 * src/data.c (Fboundp): Doc fix re lexical-binding. 2012-11-27 15:45:30 -05:00
Glenn Morris
14d2734642 * src/data.c (Fsymbol_value): Doc fix re lexical-binding. 2012-11-27 15:41:52 -05:00
Kenichi Handa
45d0fdd8f0 merge trunk 2012-11-27 22:03:42 +09:00
Paul Eggert
350e0088e1 Assume POSIX 1003.1-1988 or later for grp.h, pwd.h.
* dired.c (stat_uname, stat_gname):
* fileio.c (Fexpand_file_name): Remove no-longer-needed casts.
2012-11-26 21:38:42 -08:00
Paul Eggert
22626a856b Assume POSIX 1003.1-1988 or later for errno.h.
* lib-src/movemail.c (main): Assume EAGAIN and EBUSY.
* src/dired.c (directory_files_internal, file_name_completion):
Assume EAGAIN and EINTR are defined.
* src/fileio.c (Fcopy_file): Assume EISDIR is defined.
* src/gmalloc.c (ENOMEM, EINVAL): Assume they're defined.
* src/gnutls.c (emacs_gnutls_write): Assume EAGAIN is defined.
* src/lread.c (readbyte_from_file): Assume EINTR is defined.
* src/process.c (wait_reading_process_output, send_process) [subprocesses]:
Assume EIO and EAGAIN are defined.
* src/unexcoff.c (write_segment): Assume EFAULT is defined.

Fixes: debbugs:12968
2012-11-26 21:17:07 -08:00
Glenn Morris
5c9cf0a3f9 Merge from emacs-24; up to 2012-11-20T20:06:17Z!monnier@iro.umontreal.ca 2012-11-26 19:10:32 -08:00
Eli Zaretskii
3fa1e84d43 Don't crash if internal-char-font is called on non-GUI frames.
src/fontset.c (Finternal_char_font): Return nil on non-GUI frames.
 (Bug#11964)
2012-11-26 19:46:35 +02:00
Paul Eggert
5fbab05122 * sysdep.c (sys_subshell): Don't assume pid_t fits in int. 2012-11-24 23:50:55 -08:00
Ken Brown
bcd77a2ba0 Remove HAVE_MOUSE; see https://lists.gnu.org/archive/html/emacs-devel/2012-10/msg00403.html.
* configure.ac (HAVE_MOUSE): Remove.
* admin/CPP-DEFINES (HAVE_MOUSE): Remove.
* msdos/sed2v2.inp (HAVE_MOUSE): Remove.
* nt/config.nt (HAVE_MOUSE): Remove.
* src/keyboard.c (HAVE_MOUSE):
* src/frame.c (HAVE_MOUSE): Remove, and rewrite code as if HAVE_MOUSE
were always defined.
2012-11-24 12:20:49 -05:00
Paul Eggert
d454751173 Revert recent change for Bug#8855.
As reported by Harald Hanche-Olsen in
<http://lists.gnu.org/archive/html/emacs-devel/2012-11/msg00445.html>
the change introduces a further bug, of creating lots of zombie
processes in some cases.  Further work is needed to come up with a
better fix for Bug#8855.
2012-11-24 00:24:11 -08:00
Eli Zaretskii
22294a56e8 Fix assertion violations when clicking on Info bread-crumbs.
src/xdisp.c (draw_glyphs): Don't draw in mouse face if mouse
 highlighting on the frame was cleared.  Prevents assertion
 violations when repeatedly clicking on the "Top" link of the
 "bread-crumbs" in Info buffers.
2012-11-24 09:25:52 +02:00
Eli Zaretskii
259719a65d Fix ChangeLog entries for the last commit. 2012-11-24 08:24:13 +02:00
Glenn Morris
d125ca15f3 Merge from emacs-24; up to 2012-11-19T11:36:02Z!yamaoka@jpl.org 2012-11-23 17:57:09 -08:00
Paul Eggert
6d4e8f62e9 Fix a race condition with glib (Bug#8855).
This is a backport from the trunk, consisting of:

2012-11-17  Eli Zaretskii  <eliz@gnu.org>

* nt/inc/sys/wait.h: New file, with prototype of waitpid and
definitions of macros it needs.
* nt/inc/ms-w32.h (wait): Don't define, 'wait' is not used anymore.
(sys_wait): Remove prototype.
* nt/config.nt (HAVE_SYS_WAIT_H): Define to 1.
* src/w32proc.c (create_child): Don't clip the PID of the child
process to fit into an Emacs integer, as this is no longer a
restriction.
(waitpid): Rename from sys_wait.  Emulate a Posix 'waitpid' by
reaping only the process specified by PID argument, if that is
positive.  Use PID instead of dead_child to know which process to
reap.  Wait for the child to die only if WNOHANG is not in
OPTIONS.
(sys_select): Don't set dead_child.
* src/sysdep.c (wait_for_termination_1): Remove the WINDOWSNT portion,
as it is no longer needed.
* src/process.c (waitpid, WUNTRACED) [!WNOHANG]: Remove definitions,
no longer needed.
(record_child_status_change): Remove the setting of
record_at_most_one_child for the !WNOHANG case.

2012-11-03  Paul Eggert  <eggert@cs.ucla.edu>

Fix a race condition that causes Emacs to mess up glib (Bug#8855).
This is a backport from the trunk.
The symptom is a diagnostic "GLib-WARNING **: In call to
g_spawn_sync(), exit status of a child process was requested but
SIGCHLD action was set to SIG_IGN and ECHILD was received by
waitpid(), so exit status can't be returned."  The diagnostic
is partly wrong, as the SIGCHLD action is not set to SIG_IGN.
The real bug is a race condition between Emacs and glib: Emacs
does a waitpid (-1, ...) and reaps glib's subprocess by mistake,
so that glib can't find it.  Work around the bug by invoking
waitpid only on subprocesses that Emacs itself creates.
* src/process.c (create_process, record_child_status_change):
Don't use special value -1 in pid field, as the caller now must
know the pid rather than having the callee infer it.  The
inference was sometimes incorrect anyway, due to another race.
(create_process): Set new 'alive' member if child is created.
(process_status_retrieved): New function.
(record_child_status_change): Use it.
Accept negative 1st argument, which means to wait for the
processes that Emacs already knows about.  Move special-case code
for DOS_NT (which lacks WNOHANG) here, from caller.  Keep track of
processes that have already been waited for, by testing and
clearing new 'alive' member.
(CAN_HANDLE_MULTIPLE_CHILDREN): Remove, as record_child_status_change
now does this internally.
(handle_child_signal): Let record_child_status_change do all
the work, since we do not want to reap all exited child processes,
only the child processes that Emacs itself created.
* src/process.h (Lisp_Process): New boolean member 'alive'.
2012-11-23 14:20:31 -08:00
Dmitry Antipov
f418b22ee9 * frame.h (struct frame): Remove display_preempted member
since all users are dead long ago.
* nsterm.h (struct x_output): Use the only dummy member.
* w32menu.c (pending_menu_activation): Remove since not
really used.
(set_frame_menubar): Adjust user.
* w32term.h (struct x_output): Drop outdated #if 0 code.
(struct w32_output): Use bitfields for explicit_parent,
asked_for_visible and menubar_active members.  Drop
unused pending_menu_activation member.
* xterm.h (struct x_output): Drop outdated #if 0 code.
Use bitfields for explicit_parent, asked_for_visible,
has_been_visible and net_wm_state_hidden_seen members.
2012-11-23 19:39:48 +04:00
Kenichi Handa
2aaec2d9be 2012-11-23 23:36:24 +09:00
Eli Zaretskii
a879f0eaae Fix bug #12955 with building under MSYS Bash.
src/makefile.w32-in (globals.h, gl-stamp): Use $(SWITCHCHAR) instead
 of a literal "/".
 (gl-stamp): Invoke fc.exe directly, not through cmd.
2012-11-23 10:47:34 +02:00
Eli Zaretskii
24becea4a7 Fix cursor display when several display strings follow each other.
src/xdisp.c (set_cursor_from_row): Skip step 2 only if point is not
 between bpos_covered and bpos_max.  This fixes cursor display when
 several display strings follow each other.
2012-11-23 10:27:05 +02:00
Eli Zaretskii
8654a41b44 Fix pgx in .gdbinit when CHECK_LISP_OBJECT_TYPE is defined.
src/.gdbinit (pgx): If the glyph's object is a string, display the
 pointer to string data, rather than the value of the string object
 itself (which barfs under CHECK_LISP_OBJECT_TYPE).
2012-11-23 09:54:33 +02:00
Paul Eggert
95ef7787fb Assume POSIX 1003.1-1988 or later for dirent.h.
* admin/CPP-DEFINES (HAVE_CLOSEDIR, HAVE_DIRENT_H): Remove.
* admin/notes/copyright: Adjust to src/ndir.h -> nt/inc/dirent.h renaming.
* configure.ac: Do not check for dirent.h or closdir.
* nt/inc/dirent.h: Rename from ../src/ndir.h, with these changes:
(struct dirent): Rename from struct direct.  All uses changed.
* nt/inc/sys/dir.h: Remove.
* src/dired.c: Assume HAVE_DIRENT_H.
(NAMLEN): Remove, replacing with ...
(dirent_namelen): New function.  All uses changed.  Use the GNU macro
_D_EXACT_NAMELEN if available, as it's faster than strlen.
(DIRENTRY): Remove, replacing all uses with 'struct dirent'.
(DIRENTRY_NONEMPTY): Remove.  All callers now assume it's nonzero.
* src/makefile.w32-in (DIR_H): Remove.  All uses replaced with
$(NT_INC)/dirent.h.
($(BLD)/w32.$(O)): Do not depend on $(SRC)/ndir.h.
* src/ndir.h: Rename to ../nt/inc/dirent.h.
* src/sysdep.h (closedir) [!HAVE_CLOSEDIR]: Remove.
Do not include <dirent.h>; no longer needed.
* src/w32.c: Include <dirent.h> rather than "ndir.h".

Fixes: debbugs:12958
2012-11-22 23:48:43 -08:00