uutils/coreutils · error

split-error-file-descriptor-limit

Error message

split-error-file-descriptor-limit

What it means

split's instantiate_writer retries writer creation when it hits the open file-descriptor limit, closing writers and retrying. If after exhausting retries the writer still cannot be created, it prints the localized 'split-error-file-descriptor-limit' message (with the chunk count) and returns the underlying error.

Solutions

  1. Raise the fd limit: `ulimit -n 65536` before running split
  2. Reduce the number of chunks with a smaller -n/-l/-b count
  3. Use numeric-suffixes/sequential output into fewer files or pipe through a compressor to limit open files

Example fix

// before
split -n 5000 bigfile
// after
ulimit -n 65536 && split -n 5000 bigfile
Defensive patterns

Strategy: retry

Validate before calling

// pre-check fd headroom (unix)
fn can_open_n_files(n: usize) -> bool {
    let lim = unsafe { let mut r: libc::rlimit = std::mem::zeroed(); libc::getrlimit(libc::RLIMIT_NOFILE, &mut r); r.rlim_cur as usize };
    n + 16 < lim
}

Try / catch

match split(input, args) {
    Err(e) if e.to_string().contains("file-descriptor-limit") => {
        eprintln!("raise `ulimit -n` or reduce chunk count");
    }
    r => r?,
}

Prevention

When it happens

Trigger: `split -n <count>` (or -l/-b chunking) requesting more simultaneous output files than the process's RLIMIT_NOFILE allows, and the retry loop still cannot open writers.

Common situations: splitting a large file into thousands of chunks; containers with low nofile ulimit (e.g. 256 or 1024); CI environments with restrictive fd limits.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of uutils/coreutils@92995feca2 (2026-09-20). Data as JSON: /api/errors/7434d723bc581d12. Report an issue: GitHub.

Appendix: source

Thrown at src/uu/split/src/split.rs:890

            }

            // Could have hit system limit for open files.
            // Try to close one previously instantiated writer first
            for (i, out_file) in self.iter_mut().enumerate() {
                if i != idx
                    && let Some(writer) = out_file.maybe_writer.as_mut()
                {
                    writer.flush()?;
                    out_file.maybe_writer = None;
                    out_file.is_new = false;
                    count += 1;

                    // And then try to instantiate the writer again
                    continue 'loop1;
                }
            }

            // If this fails - give up and propagate the error
            uucore::show_error!(
                "{}",
                translate!("split-error-file-descriptor-limit", "count" => count)
            );
            return Err(maybe_writer.err().unwrap().into());
        }
    }

    fn get_writer(&mut self, idx: usize, settings: &Settings) -> UResult<&mut Writer> {
        if self[idx].maybe_writer.is_some() {
            Ok(self[idx].maybe_writer.as_mut().unwrap())
        } else {
            // Writer was not instantiated upfront or was temporarily closed due to system resources constraints.
            // Instantiate it and record for future use.
            self.instantiate_writer(idx, settings)
        }
    }
}

View on GitHub (pinned to 92995feca2)