1. 03 Dec, 2018 4 commits
    • Eli Zaretskii's avatar
      Fix WINDOWSNT/DOS_NT build · 2ff9dca1
      Eli Zaretskii authored
      Recent changes in sysdep.c and emacsclient unnecessarily
      removed useful code from DOS_NT builds.  This changeset
      reinstates that code.
      * nt/inc/ms-w32.h (tcdrain): Redirect to _commit.
      (fdatasync): No need to redirect anymore.
      * lib-src/emacsclient.c (flush_stdout): Don't avoid calling
      tcdrain on DOS_NT platforms.
      * src/sysdep.c (reset_sys_modes): Don't ifdef away the call to
      tcdrain on DOS_NT platforms.
    • Paul Eggert's avatar
      emacsclient: don’t leak socket to child processes · 5c412405
      Paul Eggert authored
      * lib-src/emacsclient.c [!WINDOWSNT]: Include fcntl.h.
      (cloexec_socket): New function.
      (set_tcp_socket, set_local_socket): Use it.
    • Paul Eggert's avatar
      Use tcdrain, not fdatasync, to drain ttys · f5090b91
      Paul Eggert authored
      fdatasync is for storage devices, not ttys.
      * admin/merge-gnulib (GNULIB_MODULES): Remove fdatasync.
      * lib/fdatasync.c, m4/fdatasync.m4: Remove.
      * lib-src/Makefile.in (LIB_FDATASYNC):
      * src/Makefile.in (LIB_FDATASYNC):
      Remove.  All uses removed.
      * lib-src/emacsclient.c [!DOS_NT]:
      Include <termios.h>, for tcdrain.
      * lib-src/emacsclient.c (flush_stdout):
      * src/sysdep.c (reset_sys_modes): On ttys, use tcdrain instead
      of fdatasync (except don’t use either function if DOS_NT).
      * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
    • Paul Eggert's avatar
      emacsclient: fix symlink/socket race · 3e5d7755
      Paul Eggert authored
      * lib-src/emacsclient.c (socket_status): New arg UID.
      All uses changed.
      (set_local_socket): Don’t create the unbound socket unless the
      initial sanity checks on the socket file succeed; this
      simplifies cleaning it up.  Check socket ownership again
      after connecting, to fix a race (Bug#33366).
  2. 02 Dec, 2018 1 commit
    • Paul Eggert's avatar
      emacsclient: prefer XDG_RUNTIME_DIR (Bug#33367) · 92282cb5
      Paul Eggert authored
      * lib-src/emacsclient.c: Disable -Wformat-truncation=2,
      to avoid false alarms about the new snprintf calls.
      (local_sockname): New function.
      (set_local_socket): Use it.  Prefer XDG_RUNTIME_DIR (if set)
      for location of socket directory.  Avoid unnecessary memory
      allocation by using snprintf to destination.
      * lisp/server.el (server-socket-dir): Prefer XDG_RUNTIME_DIR if set.
  3. 26 Nov, 2018 4 commits
    • Eli Zaretskii's avatar
      Unbreak compilation of emacsclient on MS-Windows · 038b425c
      Eli Zaretskii authored
      * lib-src/emacsclient.c (main): Make "-suspend" handling
      conditional on !WINDOWSNT, as there's no SIGSTOP nor 'kill'
    • Paul Eggert's avatar
      emacsclient: assume HAVE_INET_SOCKETS · ed3ae3fc
      Paul Eggert authored
      * configure.ac (HAVE_INET_SOCKETS): Remove.
      * lib-src/emacsclient.c: Simplify by assuming HAVE_SOCKETS and
      HAVE_INET_SOCKETS, which are always true nowadays, except perhaps
      for MS-DOS and if so this program shouldn’t be built there anyway.
      Don’t bother including sys/types.h, as it’s not needed on modern
      systems (and syswait.h does it for us anyway).
      (main): Simplify by assuming SIGSTOP (which is always defined
      if SIGCONT is), and by assuming HAVE_SOCKETS && HAVE_INET_SOCKETS.
    • Paul Eggert's avatar
      emacsclient: negate NO_SOCKETS_IN_FILE_SYSTEM · 5c1bf596
      Paul Eggert authored
      * lib-src/emacsclient.c (SOCKETS_IN_FILE_SYSTEM): Rename from
      NO_SOCKETS_IN_FILE_SYSTEM, with inverted sense.  All uses changed.
      All uses were of the form ‘#ifndef NO_SOCKETS_IN_FILE_SYSTEM’, and
      it’s easier to read ‘#ifdef SOCKETS_IN_FILE_SYSTEM’.
    • Paul Eggert's avatar
      emacsclient: fix some races on POSIX systems · 0331f2f4
      Paul Eggert authored
      Fix some longstanding race conditions due to emacsclient’s use of
      ‘signal’ instead of ‘sigaction’ and its use of nested signal
      handlers.  These races could cause premature exit or incorrect
      commands sent to Emacs.
      * lib-src/emacsclient.c (signal) [!WINDOWSNT]: Do not undef.
      (emacs_socket): Remove this static variable.  It is now a parameter.
      (send_to_emacs): Do not exit merely because ‘send’ was interrupted.
      Instead, act on the signal if possible, and then retry the ‘send’.
      (pass_signal_to_emacs): Remove; now done by act_on_signals.
      (reinstall_handler_if_needed, handle_sigttou, handle_sigwinch)
      (install_handler): New functions.
      (got_sigcont, got_sigtstp, got_sigttou, got_sigwinch):
      New globals, used for more-portable signal handling.
      (handle_sigcont, handle_sigtstp): Just set the static var; other
      actions are now done later by act_on_signals.
      (install_handler): New function that arranges for signals to
      never be reset to default, on modern POSIX platforms.
      This fixes some races.
      (act_on_signals): New function.  When acting on SIGCONT,
      don’t bother calling getpgrp if tcgetpgrp fails.
      (start_daemon_and_retry_set_socket): Return the socket
      rather than setting a global variable.  All uses changed.
      (flush_stdout): New function that acts on signals received while
      (main): Use it.  emacs_socket is now a local var.
      Act on signals received during recv.
  4. 23 Nov, 2018 4 commits
    • Eli Zaretskii's avatar
      Avoid compilation warning in emacsclient.c · 2b1bc701
      Eli Zaretskii authored
      * lib-src/emacsclient.c (set_tcp_socket): Avoid compilation
      warning in MS-Windows build.
    • Paul Eggert's avatar
      emacsclient: fix child exit when exec fails · 652dabff
      Paul Eggert authored
      * lib-src/emacsclient.c (start_daemon_and_retry_set_socket):
      If the execvp of Emacs fails exit instead of having the child
      run on and do the work of the parent.  Coalesce duplicate code.
    • Paul Eggert's avatar
      emacsclient: one ‘main’ function · ef1f6030
      Paul Eggert authored
      * lib-src/emacsclient.c (main): Simplify by having just one
      ‘main’ function instead of two.  Don’t assume argc is positive (!).
    • Paul Eggert's avatar
      emacsclient: tidy socket failure cleanup · 5daba9d8
      Paul Eggert authored
      * lib-src/emacsclient.c (set_tcp_socket, set_local_socket):
      Close socket (instead of leaking it) when ‘connect’ fails.
      (socket_status): Return errno if stat fails and -1 if we don’t own.
      (set_local_socket): Simplify based on socket_status change.
  5. 22 Nov, 2018 3 commits
    • Paul Eggert's avatar
      emacsclient: coalesce WINDOWSNT-specific code · 7a85753d
      Paul Eggert authored
      * lib-src/emacsclient.c (sock_err_message) [WINDOWSNT]:
      Do nothing if w32_window_app () && alternate_editor.
      Both callers changed.
    • Paul Eggert's avatar
      emacsclient: sockaddr portability fixes · 5773470f
      Paul Eggert authored
      * lib-src/emacsclient.c (get_server_config, set_tcp_socket)
      (set_local_socket): Initialize any platform-specific extensions
      of struct to zero, just in case.
      (set_tcp_socket, set_local_socket): Don’t assume struct
      layout details that POSIX does not specify.
      Use union to sidestep some problems with strict aliasing.
      Remove unnecessary casts.
    • Paul Eggert's avatar
      emacsclient: getopt minor cleanup · ad063d25
      Paul Eggert authored
      * lib-src/emacsclient.c (shortopts): New constant.
      (decode_options): Use it.  Do not assume EOF == -1.
  6. 21 Nov, 2018 5 commits
    • Paul Eggert's avatar
      emacsclient: omit EXTRA_SPACE guesswork · 0f22bf09
      Paul Eggert authored
      * lib-src/emacsclient.c: Include <intprops.h>.
      (EXTRA_SPACE): Remove; code no longer guesses this is enough.
      (open_config): New function.
      (get_server_config): Use it.
      (set_local_socket): Compute upper bound of buffer size
      instead of guessing via EXTRA_SPACE.
    • Paul Eggert's avatar
      emacsclient: take more care with int width · 8f49cb00
      Paul Eggert authored
      * lib-src/emacsclient.c: Include inttypes.h, stddef.h.
      (emacs_pid, main): Don’t assume pid fits in int.
      (fail): Don’t assume pointer difference fits in int.
      (set_local_socket): Don’t assume uid fits in long.
    • Paul Eggert's avatar
      emacsclient.c: use C99 to avoid {} · c0870736
      Paul Eggert authored
      * lib-src/emacsclient.c (set_local_socket):
      Assume C99 decl-after-statement and reindent.
    • Paul Eggert's avatar
      emacsclient: improve use of locals · 3fe110d3
      Paul Eggert authored
      * lib-src/emacsclient.c (main):
      Use smaller scopes for some locals.
    • Paul Eggert's avatar
      emacsclient: fix unlikely crash with "&" · 7a85a40e
      Paul Eggert authored
      * lib-src/emacsclient.c (quote_argument):
      Mention *DATA in comment so it’s clear DATA must be non-null.
      (quote_argument, unquote_argument): Simplify.
      (unquote_argument): Don’t crash if the string ends in "&".
  7. 19 Nov, 2018 9 commits
    • Eli Zaretskii's avatar
      Fix last change · 008bc1cb
      Eli Zaretskii authored
      * lib-src/emacsclient.c (start_daemon_and_retry_set_socket)
      [!WINDOWSNT]: Condition usage of socket_name on
      NO_SOCKETS_IN_FILE_SYSTEM being undefined.
    • Eli Zaretskii's avatar
      Avoid compiler warning in emacsclient.c · 57d5c14d
      Eli Zaretskii authored
      * lib-src/emacsclient.c (socket_name): Define only if
      NO_SOCKETS_IN_FILE_SYSTEM is not defined, to avoid a compiler
    • Paul Eggert's avatar
      emacsclient.c: file name component fixes · 0e3b2458
      Paul Eggert authored
      * lib-src/emacsclient.c: Include <dosname.h>.
      (file_name_absolute_p): Remove, as a code duplicate.
      All uses replaced by IS_ABSOLUTE_FILE_NAME.
      (set_local_socket): Don’t treat \ as a file name separator
      on GNU and POSIX hosts.
    • Paul Eggert's avatar
      emacsclient.c: reindent to fit in 80 · 736f1b36
      Paul Eggert authored
      * lib-src/emacsclient.c: Reindent slightly.
    • Paul Eggert's avatar
      emacsclient.c: use C99 better · b944e886
      Paul Eggert authored
      * lib-src/emacsclient.c (get_current_dir_name)
      (send_to_emacs, set_tcp_socket, set_local_socket, main):
      Take advantage of C99 stmt before decl.
    • Paul Eggert's avatar
      emacsclient.c: use STDOUT_FILENO · 95ea5c25
      Paul Eggert authored
      * lib-src/emacsclient.c (find_tty, handle_sigcont, main):
      Use STDOUT_FILENO instead of fileno (stdout) or magic 1.
    • Paul Eggert's avatar
      emacsclient.c: use bool for boolean · 51f9c5a6
      Paul Eggert authored
      * lib-src/emacsclient.c (nowait, quiet, suppress_output, eval, tty)
      (decode_options, file_name_absolute_p, get_server_config)
      (strprefix, find_tty, set_socket, main):
      Use bool for boolean.
      (create_frame): New static var, replacing the old current_frame
      and with inverted sense, as this is clearer.
    • Paul Eggert's avatar
      emacsclient.c: make identifiers more local · 9f47bb22
      Paul Eggert authored
      * lib-src/emacsclient.c (progname, main_argc, main_argv):
      (nowait, quiet, suppress_output, eval, current_frame, display):
      (alt_display, parent_id, tty, alternate_editor, socket_name):
      (server_file, tramp_prefix, emacs_pid, frame_parameters):
      (longopts, xstrdup, send_bufffer, sblen, emacs_socket):
      Now static.
      (SEND_BUFFER_SIZE, send_buffer, sblen):
      Now local to send_to_emacs.
    • Paul Eggert's avatar
      emacsclient.c: clean up preprocessing directives · 4a5034d8
      Paul Eggert authored
      * lib-src/emacsclient.c [WINDOWSNT]: Omit duplicate stdlib.h include.
      Include min-max.h.
      (EXIT_SUCCESS, EXIT_FAILURE, min): Remove; no longer needed.
      (AUTH_KEY_LENGTH, SEND_BUFFER_SIZE): Now constants instead of macros.
  8. 13 Nov, 2018 1 commit
  9. 27 Oct, 2018 1 commit
    • Daniel Pittman's avatar
      Add support in emacsclient for EMACS_SOCKET_NAME · 3e81e9a0
      Daniel Pittman authored
      If the '--socket-name' argument is unspecified, the environment
      variable 'EMACS_SOCKET_NAME' is now consulted with the same
      semantics.  This mirrors the behavior of the '--server-file' argument,
      and allows for easier configuration of emacsclient when the socket is
      in a location other than 'TMPDIR' or '/tmp'.
      * emacsclient.c (set_socket): Add support for the
      EMACS_SOCKET_NAME environment variable.  (Bug#33095)
      * misc.texi (emacsclient Options):
      * emacsclient.1: Document the EMACS_SOCKET_NAME environment
      * etc/NEWS: Announce the new feature.
      Copyright-paperwork-exempt: yes
  10. 08 Aug, 2018 1 commit
  11. 01 May, 2018 1 commit
    • Paul Eggert's avatar
      Port --enable-gcc-warnings to GCC 8 · 65ac2778
      Paul Eggert authored
      Backport from master.
      * lib-src/emacsclient.c (fail):
      Do not dereference a null pointer.
      * src/frame.c (delete_frame):
      Add a decl with UNINIT to work around GCC bug 85563.
      * src/menu.h (finish_menu_items):
      Do not use attribute const.
      * src/regex.c (analyze_first): Use FALLTHROUGH, not a comment.
  12. 28 Apr, 2018 1 commit
    • Paul Eggert's avatar
      Port --enable-gcc-warnings to GCC 8 · 8c3215e7
      Paul Eggert authored
      * configure.ac: Do not use GCC 8’s new -Wcast-align flag.
      * lib-src/ebrowse.c (xmalloc):
      * lib-src/emacsclient.c (xmalloc, xstrdup):
      * lib-src/etags.c (xmalloc):
      * lib-src/make-docfile.c (xmalloc):
      * lib-src/movemail.c (xmalloc):
      * src/dispnew.c (new_glyph_pool):
      * src/regex.c (xmalloc):
      * src/term.c (tty_menu_create):
      * src/tparam.h (tparam):
      Use ATTRIBUTE_MALLOC.  Also see GCC bug 85562.
      * lib-src/emacsclient.c (fail):
      Do not dereference a null pointer.
      * src/frame.c (delete_frame):
      Add a decl with UNINIT to work around GCC bug 85563.
      * src/menu.h (finish_menu_items):
      Do not use attribute const.
      * src/regex.c (analyze_first): Use FALLTHROUGH, not a comment.
  13. 01 Jan, 2018 1 commit
  14. 13 Sep, 2017 1 commit
    • Paul Eggert's avatar
      Prefer HTTPS to FTP and HTTP in documentation · bc511a64
      Paul Eggert authored
      Most of this change is to boilerplate commentary such as license URLs.
      This change was prompted by ftp://ftp.gnu.org's going-away party,
      planned for November.  Change these FTP URLs to https://ftp.gnu.org
      instead.  Make similar changes for URLs to other organizations moving
      away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
      fsf.org when this works, as this will further help defend against
      man-in-the-middle attacks (for this part I omitted the MS-DOS and
      MS-Windows sources and the test tarballs to keep the workload down).
      HTTPS is not fully working to lists.gnu.org so I left those URLs alone
      for now.
  15. 30 Aug, 2017 1 commit
    • Reuben Thomas's avatar
      Add support for arguments in emacsclient's ALTERNATE_EDITOR (Bug #25082) · 98f01a13
      Reuben Thomas authored
      * lib-src/emacsclient.c (fail): Parse ALTERNATE_EDITOR, or
      corresponding command-line argument, into quote- or space-separated
      tokens.  If a token starts with a quote, then it naturally is expected
      to end with a quote; escaping is not supported. This is enough to cope
      with the typical case of requiring the initial path to be quoted,
      common on Windows where it may contain spaces.
      * etc/NEWS: Document.
      * doc/emacs/misc.texi: Likewise.
      * doc/man/emacsclient.1: Tweak to remove the implication that only an
      editor can be specified (the manual already mentions a “command”).
      Fix a small error where “EDITOR” is referred to rather than
      * test/lib-src/emacsclient-tests.el: Add tests.
  16. 07 Aug, 2017 2 commits