diff options
| author | YAMAMOTO Mitsuharu | 2020-04-15 10:04:21 +0200 |
|---|---|---|
| committer | Robert Pluim | 2020-04-15 11:55:16 +0200 |
| commit | d87a4d1f4e1a84b2a527ebe5a04516f47d4717ea (patch) | |
| tree | 03d8c26affb65155417f52c1de0b34209ce0ba13 /src | |
| parent | e5ca8e5e73acbe9147203d1365365626fc35441e (diff) | |
| download | emacs-d87a4d1f4e1a84b2a527ebe5a04516f47d4717ea.tar.gz emacs-d87a4d1f4e1a84b2a527ebe5a04516f47d4717ea.zip | |
Limit RLIMIT_NOFILE to FD_SETSIZE on macOS
* src/nsterm.m ([EmacsApp applicationDidFinishLaunching:]): Call
CoreFoundation functions that increase RLIMIT_NOFILE behind our back
during startup, and then set RLIMIT_NOFILE back to FD_SETSIZE to avoid
crashes in setup_process_coding_system (Bug#39164).
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index e92e3d5a6f5..ac467840a25 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -5812,6 +5812,21 @@ ns_term_shutdown (int sig) | |||
| 5812 | #endif | 5812 | #endif |
| 5813 | 5813 | ||
| 5814 | #ifdef NS_IMPL_COCOA | 5814 | #ifdef NS_IMPL_COCOA |
| 5815 | /* Some functions/methods in CoreFoundation/Foundation increase the | ||
| 5816 | maximum number of open files for the process in their first call. | ||
| 5817 | We make dummy calls to them and then reduce the resource limit | ||
| 5818 | here, since pselect cannot handle file descriptors that are | ||
| 5819 | greater than or equal to FD_SETSIZE. */ | ||
| 5820 | CFSocketGetTypeID (); | ||
| 5821 | CFFileDescriptorGetTypeID (); | ||
| 5822 | [[NSFileHandle alloc] init]; | ||
| 5823 | struct rlimit rlim; | ||
| 5824 | if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 | ||
| 5825 | && rlim.rlim_cur > FD_SETSIZE) | ||
| 5826 | { | ||
| 5827 | rlim.rlim_cur = FD_SETSIZE; | ||
| 5828 | setrlimit (RLIMIT_NOFILE, &rlim); | ||
| 5829 | } | ||
| 5815 | if ([NSApp activationPolicy] == NSApplicationActivationPolicyProhibited) { | 5830 | if ([NSApp activationPolicy] == NSApplicationActivationPolicyProhibited) { |
| 5816 | /* Set the app's activation policy to regular when we run outside | 5831 | /* Set the app's activation policy to regular when we run outside |
| 5817 | of a bundle. This is already done for us by Info.plist when we | 5832 | of a bundle. This is already done for us by Info.plist when we |