commit b6d9613df83813609ef80da45975e70954d1fb6d (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Sun Nov 6 22:55:30 2016 -0800 Restore file descriptor limit in subprocesses Problem reported by Philipp Stephani (Bug#24869). * src/callproc.c (child_setup) [!DOS_NT]: Call restore_nofile_limit in the child. * src/process.c (nofile_limit) [HAVE_SETRLIMIT]: New static var. (restore_nofile_limit): New function. (init_process_emacs) [HAVE_SETRLIMIT]: Set the new var. diff --git a/src/callproc.c b/src/callproc.c index 8ed2855..dc3ca4a 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1315,6 +1315,9 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, #else /* not WINDOWSNT */ #ifndef MSDOS + + restore_nofile_limit (); + /* Redirect file descriptors and clear the close-on-exec flag on the redirected ones. IN, OUT, and ERR are close-on-exec so they need not be closed explicitly. */ diff --git a/src/process.c b/src/process.c index d27b57d..d68c930 100644 --- a/src/process.c +++ b/src/process.c @@ -42,6 +42,11 @@ along with GNU Emacs. If not, see . */ #ifdef HAVE_SETRLIMIT # include + +/* If NOFILE_LIMIT.rlim_cur is greater than FD_SETSIZE, then + NOFILE_LIMIT is the initial limit on the number of open files, + which should be restored in child processes. */ +static struct rlimit nofile_limit; #endif /* Are local (unix) sockets supported? */ @@ -7770,6 +7775,17 @@ catch_child_signal (void) } #endif /* subprocesses */ +/* Limit the number of open files to the value it had at startup. */ + +void +restore_nofile_limit (void) +{ +#ifdef HAVE_SETRLIMIT + if (FD_SETSIZE < nofile_limit.rlim_cur) + setrlimit (RLIMIT_NOFILE, &nofile_limit); +#endif +} + /* This is not called "init_process" because that is the name of a Mach system call, so it would cause problems on Darwin systems. */ @@ -7796,12 +7812,15 @@ init_process_emacs (int sockfd) } #ifdef HAVE_SETRLIMIT - /* Don't allocate more than FD_SETSIZE file descriptors. */ - struct rlimit rlim; - if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && FD_SETSIZE < rlim.rlim_cur) + /* Don't allocate more than FD_SETSIZE file descriptors for Emacs itself. */ + if (getrlimit (RLIMIT_NOFILE, &nofile_limit) != 0) + nofile_limit.rlim_cur = 0; + else if (FD_SETSIZE < nofile_limit.rlim_cur) { + struct rlimit rlim = nofile_limit; rlim.rlim_cur = FD_SETSIZE; - setrlimit (RLIMIT_NOFILE, &rlim); + if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) + nofile_limit.rlim_cur = 0; } #endif diff --git a/src/process.h b/src/process.h index 9926050..24c6282 100644 --- a/src/process.h +++ b/src/process.h @@ -265,6 +265,7 @@ extern void delete_read_fd (int fd); extern void add_write_fd (int fd, fd_callback func, void *data); extern void delete_write_fd (int fd); extern void catch_child_signal (void); +extern void restore_nofile_limit (void); #ifdef WINDOWSNT extern Lisp_Object network_interface_list (void); commit f1d19d1445a8e7d4ee0d13edb8ed99e222603086 Author: Mark Oteiza Date: Sun Nov 6 12:09:38 2016 -0500 ; Reword diff --git a/etc/NEWS b/etc/NEWS index 7dc95de..b88440a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -530,7 +530,7 @@ variable. ** Some obsolete functions, variables, and faces have been removed: *** From subr.el: window-dot, set-window-dot, read-input, show-buffer, eval-current-buffer, string-to-int -*** Many variables pointing to face symbols obsoleted in 22.1 +*** Many variables obsoleted in 22.1 referring to face symbols +++ ** The variable 'text-quoting-style' no longer affects the treatment commit 949144c279e07e870ef4ee2de38787420b749828 Author: Mark Oteiza Date: Sun Nov 6 11:53:47 2016 -0500 Remove some subr.el functions obsoleted in 22.1 * etc/NEWS: Document removed functions. Also mention the "face" variables that have been removed recently. * lisp/subr.el (window-dot, set-window-dot, read-input, show-buffer): (eval-current-buffer, string-to-int, insert-string, makehash): Remove. diff --git a/etc/NEWS b/etc/NEWS index 4bf5332..7dc95de 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -527,6 +527,11 @@ mode bindings: 'C-c @ C-a', 'C-c @ C-t', 'C-c @ C-d', and 'C-c @ C-e.' before running. This is controlled by the 'grep-save-buffers' variable. +** Some obsolete functions, variables, and faces have been removed: +*** From subr.el: window-dot, set-window-dot, read-input, show-buffer, +eval-current-buffer, string-to-int +*** Many variables pointing to face symbols obsoleted in 22.1 + +++ ** The variable 'text-quoting-style' no longer affects the treatment of curved quotes in format arguments to functions like 'message' and diff --git a/lisp/subr.el b/lisp/subr.el index a713b92..b5c1189 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1291,13 +1291,6 @@ be a list of the form returned by `event-start' and `event-end'." ;;;; Obsolescent names for functions. -(define-obsolete-function-alias 'window-dot 'window-point "22.1") -(define-obsolete-function-alias 'set-window-dot 'set-window-point "22.1") -(define-obsolete-function-alias 'read-input 'read-string "22.1") -(define-obsolete-function-alias 'show-buffer 'set-window-buffer "22.1") -(define-obsolete-function-alias 'eval-current-buffer 'eval-buffer "22.1") -(define-obsolete-function-alias 'string-to-int 'string-to-number "22.1") - (make-obsolete 'forward-point "use (+ (point) N) instead." "23.1") (make-obsolete 'buffer-has-markers-at nil "24.3") @@ -1307,18 +1300,6 @@ be a list of the form returned by `event-start' and `event-end'." (make-obsolete 'string-to-multibyte "use `decode-coding-string'." "25.2") (make-obsolete 'string-as-multibyte "use `decode-coding-string'." "25.2") -(defun insert-string (&rest args) - "Mocklisp-compatibility insert function. -Like the function `insert' except that any argument that is a number -is converted into a string by expressing it in decimal." - (declare (obsolete insert "22.1")) - (dolist (el args) - (insert (if (integerp el) (number-to-string el) el)))) - -(defun makehash (&optional test) - (declare (obsolete make-hash-table "22.1")) - (make-hash-table :test (or test 'eql))) - (defun log10 (x) "Return (log X 10), the log base 10 of X." (declare (obsolete log "24.4"))