{"record":{"id":"dd308ae2b42646c4","repo":"uutils/coreutils","slug":"error-writing-standard-output-err","errorCode":null,"errorMessage":"error writing 'standard output': {$err}","messagePattern":"error writing 'standard output': (.+?)","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src/uu/head/src/head.rs","lineNumber":209,"sourceCode":"        options.verbose = matches.get_flag(options::VERBOSE);\n        options.line_ending = LineEnding::from_zero_flag(matches.get_flag(options::ZERO));\n        options.presume_input_pipe = matches.get_flag(options::PRESUME_INPUT_PIPE);\n\n        options.mode = Mode::from(matches)?;\n        // #[allow(clippy::unwrap_used, reason = \"clap provides '-' by default\")] <https://github.com/rust-lang/rust/issues/15701>\n        options.files = matches\n            .get_many::<OsString>(options::FILES)\n            .unwrap()\n            .cloned()\n            .collect();\n\n        Ok(options)\n    }\n}\n\n#[inline]\nfn wrap_in_stdout_error(err: io::Error) -> io::Error {\n    io::Error::new(\n        err.kind(),\n        translate!(\"head-error-writing-stdout\", \"err\" => uucore::error::strip_errno(&err)),\n    )\n}\n\n// zero-copy fast-path\n#[cfg(any(target_os = \"linux\", target_os = \"android\"))]\nfn print_n_bytes(input: impl AsFd, n: u64) -> io::Result<u64> {\n    let out = io::stdout();\n    uucore::pipes::send_n_bytes(input, &out, n).map_err(wrap_in_stdout_error)\n}\n\n#[cfg(not(any(target_os = \"linux\", target_os = \"android\")))]\nfn print_n_bytes(input: impl Read, n: u64) -> io::Result<u64> {\n    // Read the first `n` bytes from the `input` reader.\n    let mut reader = input.take(n);\n\n    // Write those bytes to `stdout`.","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/uutils/coreutils/blob/8b8cbfd51bec3a2cc5aec7d50e1c86ac83d29766/src/uu/head/src/head.rs#L191-L227","documentation":"Error \"error writing 'standard output': {$err}\" thrown in uutils/coreutils.","triggerScenarios":"Occurs when head fails to write to standard output, typically because stdout was closed early (EPIPE) or an I/O error occurred.","commonSituations":"Piping head into a command that exits immediately (e.g. `head -n100 file | true`), or redirecting output to a full or failing device.","solutions":["Check that stdout is writable and the consumer did not close the pipe (avoid SIGPIPE).","Free disk space if the error is ENOSPC when stdout is redirected to a file."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8b8cbfd51bec3a2cc5aec7d50e1c86ac83d29766","analyzedAt":"2026-08-19T21:43:27.871Z","contentChangedAt":"2026-08-19T21:43:27.871Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}